| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,122 +2,113 @@ | |||
| 2 | 2 | * Test the limited C API. | |
| 3 | 3 | * | |
| 4 | 4 | * The 'test_*' functions exported by this module are run as part of the | |
| 5 | - * standard Python regression test, via Lib/test/test_capi.py. | ||
| 5 | + * standard Python regression test, via Lib/test/test_capi/test_misc.py. | ||
| 6 | 6 | */ | |
| 7 | 7 | ||
| 8 | - #include "pyconfig.h" // Py_GIL_DISABLED | ||
| 9 | - | ||
| 10 | - #ifdef Py_GIL_DISABLED | ||
| 11 | - // Cannot test the limited C API | ||
| 12 | - #else | ||
| 13 | - // Use the oldest limited C API version | ||
| 14 | - # define Py_LIMITED_API 0x03020000 | ||
| 15 | - #endif | ||
| 16 | - | ||
| 17 | 8 | #include "_testlimitedcapi/parts.h" | |
| 18 | 9 | ||
| 19 | - static PyMethodDef TestMethods[] = { | ||
| 20 | - {NULL, NULL} /* sentinel */ | ||
| 21 | - }; | ||
| 22 | - | ||
| 23 | - static struct PyModuleDef _testlimitedcapimodule = { | ||
| 24 | - PyModuleDef_HEAD_INIT, | ||
| 25 | - .m_name = "_testlimitedcapi", | ||
| 26 | - .m_size = 0, | ||
| 27 | - .m_methods = TestMethods, | ||
| 28 | - }; | ||
| 29 | - | ||
| 30 | - PyMODINIT_FUNC | ||
| 31 | - PyInit__testlimitedcapi(void) | ||
| 10 | + static int | ||
| 11 | + module_exec(PyObject *mod) | ||
| 32 | 12 | { | |
| 33 | - PyObject *mod = PyModule_Create(&_testlimitedcapimodule); | ||
| 34 | - if (mod == NULL) { | ||
| 35 | - return NULL; | ||
| 36 | - } | ||
| 37 | - #ifdef Py_GIL_DISABLED | ||
| 38 | - PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED); | ||
| 39 | - #endif | ||
| 40 | - | ||
| 41 | 13 | if (_PyTestLimitedCAPI_Init_Abstract(mod) < 0) { | |
| 42 | - return NULL; | ||
| 14 | + return -1; | ||
| 43 | 15 | } | |
| 44 | 16 | if (_PyTestLimitedCAPI_Init_ByteArray(mod) < 0) { | |
| 45 | - return NULL; | ||
| 17 | + return -1; | ||
| 46 | 18 | } | |
| 47 | 19 | if (_PyTestLimitedCAPI_Init_Bytes(mod) < 0) { | |
| 48 | - return NULL; | ||
| 20 | + return -1; | ||
| 49 | 21 | } | |
| 50 | 22 | if (_PyTestLimitedCAPI_Init_Capsule(mod) < 0) { | |
| 51 | - return NULL; | ||
| 23 | + return -1; | ||
| 52 | 24 | } | |
| 53 | 25 | if (_PyTestLimitedCAPI_Init_Codec(mod) < 0) { | |
| 54 | - return NULL; | ||
| 26 | + return -1; | ||
| 55 | 27 | } | |
| 56 | 28 | if (_PyTestLimitedCAPI_Init_Complex(mod) < 0) { | |
| 57 | - return NULL; | ||
| 29 | + return -1; | ||
| 58 | 30 | } | |
| 59 | 31 | if (_PyTestLimitedCAPI_Init_Dict(mod) < 0) { | |
| 60 | - return NULL; | ||
| 32 | + return -1; | ||
| 61 | 33 | } | |
| 62 | 34 | if (_PyTestLimitedCAPI_Init_Eval(mod) < 0) { | |
| 63 | - return NULL; | ||
| 35 | + return -1; | ||
| 64 | 36 | } | |
| 65 | 37 | if (_PyTestLimitedCAPI_Init_Float(mod) < 0) { | |
| 66 | - return NULL; | ||
| 38 | + return -1; | ||
| 67 | 39 | } | |
| 68 | 40 | if (_PyTestLimitedCAPI_Init_HeaptypeRelative(mod) < 0) { | |
| 69 | - return NULL; | ||
| 41 | + return -1; | ||
| 70 | 42 | } | |
| 71 | 43 | if (_PyTestLimitedCAPI_Init_Import(mod) < 0) { | |
| 72 | - return NULL; | ||
| 44 | + return -1; | ||
| 73 | 45 | } | |
| 74 | 46 | if (_PyTestLimitedCAPI_Init_List(mod) < 0) { | |
| 75 | - return NULL; | ||
| 47 | + return -1; | ||
| 76 | 48 | } | |
| 77 | 49 | if (_PyTestLimitedCAPI_Init_Long(mod) < 0) { | |
| 78 | - return NULL; | ||
| 50 | + return -1; | ||
| 79 | 51 | } | |
| 80 | 52 | if (_PyTestLimitedCAPI_Init_Object(mod) < 0) { | |
| 81 | - return NULL; | ||
| 53 | + return -1; | ||
| 82 | 54 | } | |
| 83 | 55 | if (_PyTestLimitedCAPI_Init_PyOS(mod) < 0) { | |
| 84 | - return NULL; | ||
| 56 | + return -1; | ||
| 85 | 57 | } | |
| 86 | 58 | if (_PyTestLimitedCAPI_Init_Set(mod) < 0) { | |
| 87 | - return NULL; | ||
| 59 | + return -1; | ||
| 88 | 60 | } | |
| 89 | 61 | if (_PyTestLimitedCAPI_Init_Slots(mod) < 0) { | |
| 90 | - return NULL; | ||
| 62 | + return -1; | ||
| 91 | 63 | } | |
| 92 | 64 | if (_PyTestLimitedCAPI_Init_Sys(mod) < 0) { | |
| 93 | - return NULL; | ||
| 65 | + return -1; | ||
| 94 | 66 | } | |
| 95 | 67 | if (_PyTestLimitedCAPI_Init_ThreadState(mod) < 0) { | |
| 96 | - return NULL; | ||
| 68 | + return -1; | ||
| 97 | 69 | } | |
| 98 | 70 | if (_PyTestLimitedCAPI_Init_Tuple(mod) < 0) { | |
| 99 | - return NULL; | ||
| 71 | + return -1; | ||
| 100 | 72 | } | |
| 101 | 73 | if (_PyTestLimitedCAPI_Init_Unicode(mod) < 0) { | |
| 102 | - return NULL; | ||
| 74 | + return -1; | ||
| 103 | 75 | } | |
| 104 | 76 | if (_PyTestLimitedCAPI_Init_VectorcallLimited(mod) < 0) { | |
| 105 | - return NULL; | ||
| 77 | + return -1; | ||
| 106 | 78 | } | |
| 107 | 79 | if (_PyTestLimitedCAPI_Init_Version(mod) < 0) { | |
| 108 | - return NULL; | ||
| 80 | + return -1; | ||
| 109 | 81 | } | |
| 110 | 82 | if (_PyTestLimitedCAPI_Init_File(mod) < 0) { | |
| 111 | - return NULL; | ||
| 83 | + return -1; | ||
| 112 | 84 | } | |
| 113 | 85 | if (_PyTestLimitedCAPI_Init_Weakref(mod) < 0) { | |
| 114 | - return NULL; | ||
| 86 | + return -1; | ||
| 115 | 87 | } | |
| 116 | 88 | if (_PyTestLimitedCAPI_Init_Run(mod) < 0) { | |
| 117 | - return NULL; | ||
| 89 | + return -1; | ||
| 118 | 90 | } | |
| 119 | 91 | if (_PyTestLimitedCAPI_Init_Type(mod) < 0) { | |
| 120 | - return NULL; | ||
| 92 | + return -1; | ||
| 121 | 93 | } | |
| 122 | - return mod; | ||
| 94 | + return 0; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + static struct PyModuleDef _testlimitedcapimodule_def = { | ||
| 98 | + PyModuleDef_HEAD_INIT, | ||
| 99 | + .m_name = "_testlimitedcapi", | ||
| 100 | + .m_size = 0, | ||
| 101 | + .m_slots = (PyModuleDef_Slot[]){ | ||
| 102 | + {Py_mod_exec, module_exec}, | ||
| 103 | + #ifdef Py_GIL_DISABLED | ||
| 104 | + {Py_mod_gil, Py_MOD_GIL_NOT_USED}, | ||
| 105 | + #endif | ||
| 106 | + {0} | ||
| 107 | + } | ||
| 108 | + }; | ||
| 109 | + | ||
| 110 | + PyMODINIT_FUNC | ||
| 111 | + PyInit__testlimitedcapi(void) | ||
| 112 | + { | ||
| 113 | + return PyModuleDef_Init(&_testlimitedcapimodule_def); | ||
| 123 | 114 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments