File tree Expand file tree Collapse file tree
tests/packages/link-library-in-subproject/foo Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,21 @@ static PyMethodDef methods[] = {
2323 {NULL , NULL , 0 , NULL },
2424};
2525
26- static struct PyModuleDef module = {
26+ #if PY_VERSION_HEX >= 0x030F0000
27+ /* Use `PyModExport_<modname>` hook, new in Python 3.15 (PEP 793) */
28+ static PyModuleDef_Slot example_slots [] = {
29+ {Py_mod_name , "_example" },
30+ {Py_mod_methods , methods },
31+ {Py_mod_gil , Py_MOD_GIL_NOT_USED },
32+ {0 , NULL }
33+ };
34+
35+ PyMODEXPORT_FUNC PyModExport__example (void ) {
36+ return example_slots ;
37+ }
38+ #else
39+ /* Use legacy method to create a module dynamically */
40+ static struct PyModuleDef moduledef = {
2741 PyModuleDef_HEAD_INIT ,
2842 "_example" ,
2943 NULL ,
@@ -33,5 +47,17 @@ static struct PyModuleDef module = {
3347
3448PyMODINIT_FUNC PyInit__example (void )
3549{
36- return PyModule_Create (& module );
50+ PyObject * module ;
51+
52+ module = PyModule_Create (& moduledef );
53+ if (module == NULL ) {
54+ return module ;
55+ }
56+
57+ #if Py_GIL_DISABLED
58+ PyUnstable_Module_SetGIL (module , Py_MOD_GIL_NOT_USED );
59+ #endif
60+
61+ return module ;
3762}
63+ #endif
You can’t perform that action at this time.
0 commit comments