@@ -4688,57 +4688,40 @@ static PyMethodDef UMath_LinAlgMethods[] = {
4688
4688
{NULL ,NULL ,0 ,NULL }/* Sentinel */
4689
4689
};
4690
4690
4691
- static struct PyModuleDef moduledef = {
4692
- PyModuleDef_HEAD_INIT ,
4693
- UMATH_LINALG_MODULE_NAME ,
4694
- NULL ,
4695
- -1 ,
4696
- UMath_LinAlgMethods ,
4697
- NULL ,
4698
- NULL ,
4699
- NULL ,
4700
- NULL
4701
- };
4702
-
4703
- PyMODINIT_FUNC PyInit__umath_linalg (void )
4691
+ static int
4692
+ _umath_linalg_exec (PyObject * m )
4704
4693
{
4705
- PyObject * m ;
4706
4694
PyObject * d ;
4707
4695
PyObject * version ;
4708
4696
4709
- m = PyModule_Create (& moduledef );
4710
- if (m == NULL ) {
4711
- return NULL ;
4712
- }
4713
-
4714
- import_array ();
4715
- import_ufunc ();
4697
+ import_array1 (-1 );
4698
+ import_umath1 (-1 );
4716
4699
4717
4700
d = PyModule_GetDict (m );
4718
4701
if (d == NULL ) {
4719
- return NULL ;
4702
+ return -1 ;
4720
4703
}
4721
4704
4722
4705
version = PyUnicode_FromString (umath_linalg_version_string );
4723
4706
if (version == NULL ) {
4724
- return NULL ;
4707
+ return -1 ;
4725
4708
}
4726
4709
int ret = PyDict_SetItemString (d ,"__version__" ,version );
4727
4710
Py_DECREF (version );
4728
4711
if (ret < 0 ) {
4729
- return NULL ;
4712
+ return -1 ;
4730
4713
}
4731
4714
4732
4715
/* Load the ufunc operators into the module's namespace */
4733
4716
if (addUfuncs (d )< 0 ) {
4734
- return NULL ;
4717
+ return -1 ;
4735
4718
}
4736
4719
4737
4720
#if PY_VERSION_HEX < 0x30d00b3 && !HAVE_EXTERNAL_LAPACK
4738
4721
lapack_lite_lock = PyThread_allocate_lock ();
4739
4722
if (lapack_lite_lock == NULL ) {
4740
4723
PyErr_NoMemory ();
4741
- return NULL ;
4724
+ return -1 ;
4742
4725
}
4743
4726
#endif
4744
4727
@@ -4748,10 +4731,30 @@ PyMODINIT_FUNC PyInit__umath_linalg(void)
4748
4731
PyDict_SetItemString (d ,"_ilp64" ,Py_False );
4749
4732
#endif
4750
4733
4751
- #if Py_GIL_DISABLED
4752
- // signal this module supports running with the GIL disabled
4753
- PyUnstable_Module_SetGIL (m ,Py_MOD_GIL_NOT_USED );
4734
+ return 0 ;
4735
+ }
4736
+
4737
+ static struct PyModuleDef_Slot _umath_linalg_slots []= {
4738
+ {Py_mod_exec , (void * )_umath_linalg_exec },
4739
+ #if PY_VERSION_HEX >=0x030c00f0 // Python 3.12+
4740
+ {Py_mod_multiple_interpreters ,Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED },
4741
+ #endif
4742
+ #if PY_VERSION_HEX >=0x030d00f0 // Python 3.13+
4743
+ // signal that this module supports running without an active GIL
4744
+ {Py_mod_gil ,Py_MOD_GIL_NOT_USED },
4754
4745
#endif
4746
+ {0 ,NULL },
4747
+ };
4748
+
4749
+ static struct PyModuleDef moduledef = {
4750
+ PyModuleDef_HEAD_INIT ,/* m_base */
4751
+ "_umath_linalg" ,/* m_name */
4752
+ NULL ,/* m_doc */
4753
+ -1 ,/* m_size */
4754
+ UMath_LinAlgMethods ,/* m_methods */
4755
+ _umath_linalg_slots ,/* m_slots */
4756
+ };
4755
4757
4756
- return m ;
4758
+ PyMODINIT_FUNC PyInit__umath_linalg (void ) {
4759
+ return PyModuleDef_Init (& moduledef );
4757
4760
}