diff options
Diffstat (limited to 'numpy/core/src')
-rw-r--r-- | numpy/core/src/_sortmodule.c.src | 31 | ||||
-rw-r--r-- | numpy/core/src/multiarray/multiarray_tests.c.src | 28 | ||||
-rw-r--r-- | numpy/core/src/multiarray/multiarraymodule.c | 44 | ||||
-rw-r--r-- | numpy/core/src/scalarmathmodule.c.src | 36 | ||||
-rw-r--r-- | numpy/core/src/umath/umath_tests.c.src | 29 | ||||
-rw-r--r-- | numpy/core/src/umath/umathmodule.c.src | 39 |
6 files changed, 185 insertions, 22 deletions
diff --git a/numpy/core/src/_sortmodule.c.src b/numpy/core/src/_sortmodule.c.src index 28299c1a7..cd9c6c277 100644 --- a/numpy/core/src/_sortmodule.c.src +++ b/numpy/core/src/_sortmodule.c.src @@ -987,11 +987,40 @@ static struct PyMethodDef methods[] = { {NULL, NULL, 0, NULL} }; + + +#if defined(NPY_PY3K) +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "_sort", + NULL, + -1, + methods, + NULL, + NULL, + NULL, + NULL +}; +#endif + +/* Initialization function for the module */ +#if defined(NPY_PY3K) +PyObject *PyInit__sort(void) { + PyObject *m; + m = PyModule_Create(&moduledef); + if (!m) { + return NULL; + } + import_array(); + add_sortfuncs(); + return m; +} +#else PyMODINIT_FUNC init_sort(void) { - Py_InitModule("_sort", methods); import_array(); add_sortfuncs(); } +#endif diff --git a/numpy/core/src/multiarray/multiarray_tests.c.src b/numpy/core/src/multiarray/multiarray_tests.c.src index c50910709..edf5dfa0e 100644 --- a/numpy/core/src/multiarray/multiarray_tests.c.src +++ b/numpy/core/src/multiarray/multiarray_tests.c.src @@ -373,18 +373,44 @@ static PyMethodDef Multiarray_TestsMethods[] = { {NULL, NULL, 0, NULL} /* Sentinel */ }; + +#if defined(NPY_PY3K) +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "multiarray_tests", + NULL, + -1, + Multiarray_TestsMethods, + NULL, + NULL, + NULL, + NULL +}; +#endif + +#if defined(NPY_PY3K) +#define RETVAL m +PyObject *PyInit_multiarray_tests(void) +#else +#define RETVAL PyMODINIT_FUNC initmultiarray_tests(void) +#endif { PyObject *m; +#if defined(NPY_PY3K) + m = PyModule_Create(&moduledef); +#else m = Py_InitModule("multiarray_tests", Multiarray_TestsMethods); +#endif if (m == NULL) { - return; + return RETVAL; } import_array(); if (PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "cannot load umath_tests module."); } + return RETVAL; } diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 430058e37..445e17ed5 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -2265,7 +2265,7 @@ as_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds) #if defined(NPY_PY3K) PyErr_SetString(PyExc_RuntimeError, - "XXX -- not implemented!") + "XXX -- not implemented!"); return NULL; #else if (ro) { @@ -2964,15 +2964,37 @@ set_flaginfo(PyObject *d) return; } +#if defined(NPY_PY3K) +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "multiarray", + NULL, + -1, + array_module_methods, + NULL, + NULL, + NULL, + NULL +}; +#endif /* Initialization function for the module */ - +#if defined(NPY_PY3K) +#define RETVAL m +PyObject *PyInit_multiarray(void) { +#else +#define RETVAL PyMODINIT_FUNC initmultiarray(void) { +#endif PyObject *m, *d, *s; PyObject *c_api; /* Create the module and add the functions */ +#if defined(NPY_PY3K) + m = PyModule_Create(&moduledef); +#else m = Py_InitModule("multiarray", array_module_methods); +#endif if (!m) { goto err; } @@ -2993,7 +3015,7 @@ PyMODINIT_FUNC initmultiarray(void) { } PyArray_Type.tp_free = _pya_free; if (PyType_Ready(&PyArray_Type) < 0) { - return; + return RETVAL; } if (setup_scalartypes(d) < 0) { goto err; @@ -3002,25 +3024,25 @@ PyMODINIT_FUNC initmultiarray(void) { PyArrayMultiIter_Type.tp_iter = PyObject_SelfIter; PyArrayMultiIter_Type.tp_free = _pya_free; if (PyType_Ready(&PyArrayIter_Type) < 0) { - return; + return RETVAL; } if (PyType_Ready(&PyArrayMapIter_Type) < 0) { - return; + return RETVAL; } if (PyType_Ready(&PyArrayMultiIter_Type) < 0) { - return; + return RETVAL; } PyArrayNeighborhoodIter_Type.tp_new = PyType_GenericNew; if (PyType_Ready(&PyArrayNeighborhoodIter_Type) < 0) { - return; + return RETVAL; } PyArrayDescr_Type.tp_hash = PyArray_DescrHash; if (PyType_Ready(&PyArrayDescr_Type) < 0) { - return; + return RETVAL; } if (PyType_Ready(&PyArrayFlags_Type) < 0) { - return; + return RETVAL; } c_api = PyCObject_FromVoidPtr((void *)PyArray_API, NULL); PyDict_SetItemString(d, "_ARRAY_API", c_api); @@ -3094,12 +3116,12 @@ PyMODINIT_FUNC initmultiarray(void) { if (set_typeinfo(d) != 0) { goto err; } - return; + return RETVAL; err: if (!PyErr_Occurred()) { PyErr_SetString(PyExc_RuntimeError, "cannot load multiarray module."); } - return; + return RETVAL; } diff --git a/numpy/core/src/scalarmathmodule.c.src b/numpy/core/src/scalarmathmodule.c.src index 00dc8e1f4..d2be8d69c 100644 --- a/numpy/core/src/scalarmathmodule.c.src +++ b/numpy/core/src/scalarmathmodule.c.src @@ -1475,14 +1475,44 @@ static struct PyMethodDef methods[] = { {NULL, NULL, 0, NULL} }; -PyMODINIT_FUNC initscalarmath(void) { +#if defined(NPY_PY3K) +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "scalarmath", + NULL, + -1, + methods, + NULL, + NULL, + NULL, + NULL +}; +#endif + +#if defined(NPY_PY3K) +#define RETVAL m +PyObject *PyInit_scalarmath(void) +#else +#define RETVAL +PyMODINIT_FUNC +initscalarmath(void) +#endif +{ + PyObject *m; +#if defined(NPY_PY3K) + m = PyModule_Create(&moduledef); + if (!m) { + return NULL; + } +#else Py_InitModule("scalarmath", methods); +#endif import_array(); import_umath(); - if (get_functions() < 0) return; + if (get_functions() < 0) return RETVAL; add_scalarmath(); @@ -1504,5 +1534,5 @@ PyMODINIT_FUNC initscalarmath(void) { #endif saved_tables[8] = PyComplex_Type.tp_richcompare; - return; + return RETVAL; } diff --git a/numpy/core/src/umath/umath_tests.c.src b/numpy/core/src/umath/umath_tests.c.src index 32aa2091c..ed4105783 100644 --- a/numpy/core/src/umath/umath_tests.c.src +++ b/numpy/core/src/umath/umath_tests.c.src @@ -268,15 +268,40 @@ static PyMethodDef UMath_TestsMethods[] = { {NULL, NULL, 0, NULL} /* Sentinel */ }; +#if defined(NPY_PY3K) +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "umath_tests", + NULL, + -1, + UMath_TestsMethods, + NULL, + NULL, + NULL, + NULL +}; +#endif + +#if defined(NPY_PY3K) +#define RETVAL m +PyObject *PyInit_umath_tests(void) +#else +#define RETVAL PyMODINIT_FUNC initumath_tests(void) +#endif { PyObject *m; PyObject *d; PyObject *version; +#if defined(NPY_PY3K) + m = PyModule_Create(&moduledef); +#else m = Py_InitModule("umath_tests", UMath_TestsMethods); - if (m == NULL) return; +#endif + if (m == NULL) + return RETVAL; import_array(); import_ufunc(); @@ -294,4 +319,6 @@ initumath_tests(void) PyErr_SetString(PyExc_RuntimeError, "cannot load umath_tests module."); } + + return RETVAL; } diff --git a/numpy/core/src/umath/umathmodule.c.src b/numpy/core/src/umath/umathmodule.c.src index 1a5c14756..20803f68b 100644 --- a/numpy/core/src/umath/umathmodule.c.src +++ b/numpy/core/src/umath/umathmodule.c.src @@ -242,7 +242,29 @@ static struct PyMethodDef methods[] = { {NULL, NULL, 0, NULL} /* sentinel */ }; -PyMODINIT_FUNC initumath(void) { + +#if defined(NPY_PY3K) +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "umath", + NULL, + -1, + methods, + NULL, + NULL, + NULL, + NULL +}; +#endif + +#if defined(NPY_PY3K) +#define RETVAL m +PyObject *PyInit_umath(void) +#else +#define RETVAL +PyMODINIT_FUNC initumath(void) +#endif +{ PyObject *m, *d, *s, *s2, *c_api; int UFUNC_FLOATING_POINT_SUPPORT = 1; @@ -250,7 +272,14 @@ PyMODINIT_FUNC initumath(void) { UFUNC_FLOATING_POINT_SUPPORT = 0; #endif /* Create the module and add the functions */ +#if defined(NPY_PY3K) + m = PyModule_Create(&moduledef); +#else m = Py_InitModule("umath", methods); +#endif + if (!m) { + return RETVAL; + } /* Import the array */ if (_import_array() < 0) { @@ -258,12 +287,12 @@ PyMODINIT_FUNC initumath(void) { PyErr_SetString(PyExc_ImportError, "umath failed: Could not import array core."); } - return; + return RETVAL; } /* Initialize the types */ if (PyType_Ready(&PyUFunc_Type) < 0) - return; + return RETVAL; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); @@ -333,7 +362,7 @@ PyMODINIT_FUNC initumath(void) { PyDict_SetItemString(d, "conj", s); PyDict_SetItemString(d, "mod", s2); - return; + return RETVAL; err: /* Check for errors */ @@ -341,5 +370,5 @@ PyMODINIT_FUNC initumath(void) { PyErr_SetString(PyExc_RuntimeError, "cannot load umath module."); } - return; + return RETVAL; } |