1Reference: https://github.com/numpy/numpy/commit/1e424dae42a2d560520b6e053e8e60ac4205bfc7 2 3--- numpy/core/code_generators/generate_numpy_api.py.orig 2024-02-05 21:17:48 UTC 4+++ numpy/core/code_generators/generate_numpy_api.py 5@@ -118,7 +118,13 @@ _import_array(void) 6 return 0; 7 } 8 9-#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NULL; } } 10+#if (SWIG_VERSION < 0x040400) 11+#define _RETURN_VALUE NULL 12+#else 13+#define _RETURN_VALUE 0 14+#endif 15+ 16+#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return _RETURN_VALUE; } } 17 18 #define import_array1(ret) {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return ret; } } 19 20