|
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 | 8 | #include "_testlimitedcapi/parts.h" |
9 | 9 |
|
10 | | -static PyMethodDef TestMethods[] = { |
11 | | - {NULL, NULL} /* sentinel */ |
12 | | -}; |
13 | | - |
14 | | -static struct PyModuleDef _testlimitedcapimodule = { |
15 | | - PyModuleDef_HEAD_INIT, |
16 | | - .m_name = "_testlimitedcapi", |
17 | | - .m_size = 0, |
18 | | - .m_methods = TestMethods, |
19 | | -}; |
20 | | - |
21 | | -PyMODINIT_FUNC |
22 | | -PyInit__testlimitedcapi(void) |
| 10 | +static int |
| 11 | +module_exec(PyObject *mod) |
23 | 12 | { |
24 | | - PyObject *mod = PyModule_Create(&_testlimitedcapimodule); |
25 | | - if (mod == NULL) { |
26 | | - return NULL; |
27 | | - } |
28 | | -#ifdef Py_GIL_DISABLED |
29 | | - PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED); |
30 | | -#endif |
31 | | - |
32 | 13 | if (_PyTestLimitedCAPI_Init_Abstract(mod) < 0) { |
33 | | - return NULL; |
| 14 | + return -1; |
34 | 15 | } |
35 | 16 | if (_PyTestLimitedCAPI_Init_ByteArray(mod) < 0) { |
36 | | - return NULL; |
| 17 | + return -1; |
37 | 18 | } |
38 | 19 | if (_PyTestLimitedCAPI_Init_Bytes(mod) < 0) { |
39 | | - return NULL; |
| 20 | + return -1; |
40 | 21 | } |
41 | 22 | if (_PyTestLimitedCAPI_Init_Capsule(mod) < 0) { |
42 | | - return NULL; |
| 23 | + return -1; |
43 | 24 | } |
44 | 25 | if (_PyTestLimitedCAPI_Init_Codec(mod) < 0) { |
45 | | - return NULL; |
| 26 | + return -1; |
46 | 27 | } |
47 | 28 | if (_PyTestLimitedCAPI_Init_Complex(mod) < 0) { |
48 | | - return NULL; |
| 29 | + return -1; |
49 | 30 | } |
50 | 31 | if (_PyTestLimitedCAPI_Init_Dict(mod) < 0) { |
51 | | - return NULL; |
| 32 | + return -1; |
52 | 33 | } |
53 | 34 | if (_PyTestLimitedCAPI_Init_Eval(mod) < 0) { |
54 | | - return NULL; |
| 35 | + return -1; |
55 | 36 | } |
56 | 37 | if (_PyTestLimitedCAPI_Init_Float(mod) < 0) { |
57 | | - return NULL; |
| 38 | + return -1; |
58 | 39 | } |
59 | 40 | if (_PyTestLimitedCAPI_Init_HeaptypeRelative(mod) < 0) { |
60 | | - return NULL; |
| 41 | + return -1; |
61 | 42 | } |
62 | 43 | if (_PyTestLimitedCAPI_Init_Import(mod) < 0) { |
63 | | - return NULL; |
| 44 | + return -1; |
64 | 45 | } |
65 | 46 | if (_PyTestLimitedCAPI_Init_List(mod) < 0) { |
66 | | - return NULL; |
| 47 | + return -1; |
67 | 48 | } |
68 | 49 | if (_PyTestLimitedCAPI_Init_Long(mod) < 0) { |
69 | | - return NULL; |
| 50 | + return -1; |
70 | 51 | } |
71 | 52 | if (_PyTestLimitedCAPI_Init_Object(mod) < 0) { |
72 | | - return NULL; |
| 53 | + return -1; |
73 | 54 | } |
74 | 55 | if (_PyTestLimitedCAPI_Init_PyOS(mod) < 0) { |
75 | | - return NULL; |
| 56 | + return -1; |
76 | 57 | } |
77 | 58 | if (_PyTestLimitedCAPI_Init_Set(mod) < 0) { |
78 | | - return NULL; |
| 59 | + return -1; |
79 | 60 | } |
80 | 61 | if (_PyTestLimitedCAPI_Init_Slice(mod) < 0) { |
81 | | - return NULL; |
| 62 | + return -1; |
82 | 63 | } |
83 | 64 | if (_PyTestLimitedCAPI_Init_Slots(mod) < 0) { |
84 | | - return NULL; |
| 65 | + return -1; |
85 | 66 | } |
86 | 67 | if (_PyTestLimitedCAPI_Init_Sys(mod) < 0) { |
87 | | - return NULL; |
| 68 | + return -1; |
88 | 69 | } |
89 | 70 | if (_PyTestLimitedCAPI_Init_ThreadState(mod) < 0) { |
90 | | - return NULL; |
| 71 | + return -1; |
91 | 72 | } |
92 | 73 | if (_PyTestLimitedCAPI_Init_Tuple(mod) < 0) { |
93 | | - return NULL; |
| 74 | + return -1; |
94 | 75 | } |
95 | 76 | if (_PyTestLimitedCAPI_Init_Unicode(mod) < 0) { |
96 | | - return NULL; |
| 77 | + return -1; |
97 | 78 | } |
98 | 79 | if (_PyTestLimitedCAPI_Init_VectorcallLimited(mod) < 0) { |
99 | | - return NULL; |
| 80 | + return -1; |
100 | 81 | } |
101 | 82 | if (_PyTestLimitedCAPI_Init_Version(mod) < 0) { |
102 | | - return NULL; |
| 83 | + return -1; |
103 | 84 | } |
104 | 85 | if (_PyTestLimitedCAPI_Init_File(mod) < 0) { |
105 | | - return NULL; |
| 86 | + return -1; |
106 | 87 | } |
107 | 88 | if (_PyTestLimitedCAPI_Init_Weakref(mod) < 0) { |
108 | | - return NULL; |
| 89 | + return -1; |
109 | 90 | } |
110 | 91 | if (_PyTestLimitedCAPI_Init_Run(mod) < 0) { |
111 | | - return NULL; |
| 92 | + return -1; |
112 | 93 | } |
113 | 94 | if (_PyTestLimitedCAPI_Init_Type(mod) < 0) { |
114 | | - return NULL; |
| 95 | + return -1; |
115 | 96 | } |
116 | | - return mod; |
| 97 | + return 0; |
| 98 | +} |
| 99 | + |
| 100 | +static struct PyModuleDef _testlimitedcapimodule_def = { |
| 101 | + PyModuleDef_HEAD_INIT, |
| 102 | + .m_name = "_testlimitedcapi", |
| 103 | + .m_size = 0, |
| 104 | + .m_slots = (PyModuleDef_Slot[]){ |
| 105 | + {Py_mod_exec, module_exec}, |
| 106 | +#ifdef Py_GIL_DISABLED |
| 107 | + {Py_mod_gil, Py_MOD_GIL_NOT_USED}, |
| 108 | +#endif |
| 109 | + {0} |
| 110 | + } |
| 111 | +}; |
| 112 | + |
| 113 | +PyMODINIT_FUNC |
| 114 | +PyInit__testlimitedcapi(void) |
| 115 | +{ |
| 116 | + return PyModuleDef_Init(&_testlimitedcapimodule_def); |
117 | 117 | } |
0 commit comments