summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSeth Troisi <sethtroisi@google.com>2020-01-03 13:23:52 -0800
committerSebastian Berg <sebastian@sipsolutions.net>2020-01-03 15:23:52 -0600
commite1aecb08f99321b72959cc50eb7b47454b613f52 (patch)
tree369d1ad3168c7a160072d39768217d680dac3e0a /numpy
parentf30b2564d3923b2c307a026e4a22d20bc19872f0 (diff)
downloadnumpy-e1aecb08f99321b72959cc50eb7b47454b613f52.tar.gz
MAINT: Remove Python2 specific C module setup (gh-15231)
Dropping the support for python 2, the difference in module setup do not have to be accounted for anymore. This removes the macros and ifdef's related to module setup code and python 2 support.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/code_generators/generate_numpy_api.py8
-rw-r--r--numpy/core/code_generators/generate_ufunc_api.py8
-rw-r--r--numpy/core/src/dummymodule.c9
-rw-r--r--numpy/core/src/multiarray/_multiarray_tests.c.src17
-rw-r--r--numpy/core/src/multiarray/arraytypes.c.src8
-rw-r--r--numpy/core/src/multiarray/compiled_base.c4
-rw-r--r--numpy/core/src/multiarray/descriptor.c6
-rw-r--r--numpy/core/src/multiarray/item_selection.c4
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c16
-rw-r--r--numpy/core/src/umath/_operand_flag_tests.c.src18
-rw-r--r--numpy/core/src/umath/_rational_tests.c.src19
-rw-r--r--numpy/core/src/umath/_struct_ufunc_tests.c.src16
-rw-r--r--numpy/core/src/umath/_umath_tests.c.src18
-rwxr-xr-xnumpy/f2py/rules.py10
-rw-r--r--numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c12
-rw-r--r--numpy/fft/_pocketfft.c21
-rw-r--r--numpy/linalg/lapack_litemodule.c18
-rw-r--r--numpy/linalg/umath_linalg.c.src19
18 files changed, 34 insertions, 197 deletions
diff --git a/numpy/core/code_generators/generate_numpy_api.py b/numpy/core/code_generators/generate_numpy_api.py
index 5e04fb86d..efef9340f 100644
--- a/numpy/core/code_generators/generate_numpy_api.py
+++ b/numpy/core/code_generators/generate_numpy_api.py
@@ -120,13 +120,7 @@ _import_array(void)
return 0;
}
-#if PY_VERSION_HEX >= 0x03000000
-#define NUMPY_IMPORT_ARRAY_RETVAL NULL
-#else
-#define NUMPY_IMPORT_ARRAY_RETVAL
-#endif
-
-#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NUMPY_IMPORT_ARRAY_RETVAL; } }
+#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NULL; } }
#define import_array1(ret) {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return ret; } }
diff --git a/numpy/core/code_generators/generate_ufunc_api.py b/numpy/core/code_generators/generate_ufunc_api.py
index 1b0143e88..bcd37de57 100644
--- a/numpy/core/code_generators/generate_ufunc_api.py
+++ b/numpy/core/code_generators/generate_ufunc_api.py
@@ -74,12 +74,6 @@ _import_umath(void)
return 0;
}
-#if PY_VERSION_HEX >= 0x03000000
-#define NUMPY_IMPORT_UMATH_RETVAL NULL
-#else
-#define NUMPY_IMPORT_UMATH_RETVAL
-#endif
-
#define import_umath() \
do {\
UFUNC_NOFPE\
@@ -87,7 +81,7 @@ _import_umath(void)
PyErr_Print();\
PyErr_SetString(PyExc_ImportError,\
"numpy.core.umath failed to import");\
- return NUMPY_IMPORT_UMATH_RETVAL;\
+ return NULL;\
}\
} while(0)
diff --git a/numpy/core/src/dummymodule.c b/numpy/core/src/dummymodule.c
index 718199f70..e26875736 100644
--- a/numpy/core/src/dummymodule.c
+++ b/numpy/core/src/dummymodule.c
@@ -16,7 +16,6 @@ static struct PyMethodDef methods[] = {
};
-#if defined(NPY_PY3K)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"dummy",
@@ -28,10 +27,8 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
/* Initialization function for the module */
-#if defined(NPY_PY3K)
PyMODINIT_FUNC PyInit__dummy(void) {
PyObject *m;
m = PyModule_Create(&moduledef);
@@ -40,9 +37,3 @@ PyMODINIT_FUNC PyInit__dummy(void) {
}
return m;
}
-#else
-PyMODINIT_FUNC
-init_dummy(void) {
- Py_InitModule("_dummy", methods);
-}
-#endif
diff --git a/numpy/core/src/multiarray/_multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src
index fa2efb428..5e2cf0edd 100644
--- a/numpy/core/src/multiarray/_multiarray_tests.c.src
+++ b/numpy/core/src/multiarray/_multiarray_tests.c.src
@@ -2126,7 +2126,6 @@ static PyMethodDef Multiarray_TestsMethods[] = {
};
-#if defined(NPY_PY3K)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_multiarray_tests",
@@ -2138,33 +2137,21 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
-#if defined(NPY_PY3K)
-#define RETVAL m
PyMODINIT_FUNC PyInit__multiarray_tests(void)
-#else
-#define RETVAL
-PyMODINIT_FUNC
-init_multiarray_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 RETVAL;
+ return m;
}
import_array();
if (PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError,
"cannot load _multiarray_tests module.");
}
- return RETVAL;
+ return m;
}
NPY_NO_EXPORT int
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src
index 99897f9c2..077fb0ec8 100644
--- a/numpy/core/src/multiarray/arraytypes.c.src
+++ b/numpy/core/src/multiarray/arraytypes.c.src
@@ -748,7 +748,7 @@ _setup_field(int i, PyArray_Descr *descr, PyArrayObject *arr,
}
((PyArrayObject_fields *)(arr))->descr = new;
- if ((new->alignment > 1) &&
+ if ((new->alignment > 1) &&
((((uintptr_t)dstdata + offset) % new->alignment) != 0)) {
PyArray_CLEARFLAGS(arr, NPY_ARRAY_ALIGNED);
}
@@ -836,7 +836,7 @@ VOID_setitem(PyObject *op, void *input, void *vap)
if (names_size != PyTuple_Size(op)) {
errmsg = PyUString_FromFormat(
"could not assign tuple of length %zd to structure "
- "with %" NPY_INTP_FMT " fields.",
+ "with %" NPY_INTP_FMT " fields.",
PyTuple_Size(op), names_size);
PyErr_SetObject(PyExc_ValueError, errmsg);
Py_DECREF(errmsg);
@@ -3000,7 +3000,7 @@ OBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *NPY_UNUSED(ap))
ret = PyObject_RichCompareBool(*ip1, *ip2, Py_LT);
if (ret < 0) {
- /* error occurred, avoid the next call to PyObject_RichCompareBool */
+ /* error occurred, avoid the next call to PyObject_RichCompareBool */
return 0;
}
if (ret == 1) {
@@ -4429,7 +4429,7 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {
#if @rsort@
aradixsort_@suff@
#else
- atimsort_@suff@
+ atimsort_@suff@
#endif
},
#else
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c
index 055d3e60f..cc37026b0 100644
--- a/numpy/core/src/multiarray/compiled_base.c
+++ b/numpy/core/src/multiarray/compiled_base.c
@@ -1159,7 +1159,7 @@ fail:
}
-/*
+/*
* Inner loop for unravel_index
* order must be NPY_CORDER or NPY_FORTRANORDER
*/
@@ -1186,7 +1186,7 @@ unravel_index_loop(int unravel_ndim, npy_intp *unravel_dims,
}
idx = idx_start;
for (i = 0; i < unravel_ndim; ++i) {
- /*
+ /*
* Using a local seems to enable single-divide optimization
* but only if the / precedes the %
*/
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index d4e18e457..89934bbd4 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -241,7 +241,7 @@ _convert_from_tuple(PyObject *obj, int align)
if (!PyArray_DescrConverter(PyTuple_GET_ITEM(obj, 0), &type)) {
return NULL;
}
- }
+ }
val = PyTuple_GET_ITEM(obj,1);
/* try to interpret next item as a type */
res = _use_inherit(type, val, &errflag);
@@ -455,11 +455,11 @@ _convert_from_array_descr(PyObject *obj, int align)
Py_INCREF(name);
#if !defined(NPY_PY3K)
- /* convert unicode name to ascii on Python 2 if possible */
+ /* convert unicode name to ascii on Python 2 if possible */
if (PyUnicode_Check(name)) {
PyObject *tmp = PyUnicode_AsASCIIString(name);
Py_DECREF(name);
- if (tmp == NULL) {
+ if (tmp == NULL) {
goto fail;
}
name = tmp;
diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c
index a6ac902d3..e6867083f 100644
--- a/numpy/core/src/multiarray/item_selection.c
+++ b/numpy/core/src/multiarray/item_selection.c
@@ -2392,7 +2392,7 @@ PyArray_Nonzero(PyArrayObject *self)
Py_DECREF(ret);
return NULL;
}
-
+
needs_api = NpyIter_IterationNeedsAPI(iter);
NPY_BEGIN_THREADS_NDITER(iter);
@@ -2436,7 +2436,7 @@ finish:
Py_DECREF(ret);
return NULL;
}
-
+
/* if executed `nonzero()` check for miscount due to side-effect */
if (!is_bool && added_count != nonzero_count) {
PyErr_SetString(PyExc_RuntimeError,
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index 33b654729..eb593bdb5 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -4551,7 +4551,6 @@ intern_strings(void)
npy_ma_str_ndmin && npy_ma_str_axis1 && npy_ma_str_axis2;
}
-#if defined(NPY_PY3K)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_multiarray_umath",
@@ -4563,25 +4562,14 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
/* Initialization function for the module */
-#if defined(NPY_PY3K)
-#define RETVAL(x) x
PyMODINIT_FUNC PyInit__multiarray_umath(void) {
-#else
-#define RETVAL(x)
-PyMODINIT_FUNC init_multiarray_umath(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_umath", array_module_methods);
-#endif
if (!m) {
goto err;
}
@@ -4766,12 +4754,12 @@ PyMODINIT_FUNC init_multiarray_umath(void) {
if (initumath(m) != 0) {
goto err;
}
- return RETVAL(m);
+ return m;
err:
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError,
"cannot load multiarray module.");
}
- return RETVAL(NULL);
+ return NULL;
}
diff --git a/numpy/core/src/umath/_operand_flag_tests.c.src b/numpy/core/src/umath/_operand_flag_tests.c.src
index 551a9c632..15fd7be6a 100644
--- a/numpy/core/src/umath/_operand_flag_tests.c.src
+++ b/numpy/core/src/umath/_operand_flag_tests.c.src
@@ -39,7 +39,6 @@ static char types[2] = {NPY_LONG, NPY_LONG};
static void *data[1] = {NULL};
-#if defined(NPY_PY3K)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_operand_flag_tests",
@@ -52,22 +51,12 @@ static struct PyModuleDef moduledef = {
NULL
};
-#define RETVAL m
PyMODINIT_FUNC PyInit__operand_flag_tests(void)
{
-#else
-#define RETVAL
-PyMODINIT_FUNC init_operand_flag_tests(void)
-{
-#endif
PyObject *m = NULL;
PyObject *ufunc;
-#if defined(NPY_PY3K)
m = PyModule_Create(&moduledef);
-#else
- m = Py_InitModule("_operand_flag_tests", TestMethods);
-#endif
if (m == NULL) {
goto fail;
}
@@ -87,19 +76,16 @@ PyMODINIT_FUNC init_operand_flag_tests(void)
((PyUFuncObject*)ufunc)->iter_flags = NPY_ITER_REDUCE_OK;
PyModule_AddObject(m, "inplace_add", (PyObject*)ufunc);
- return RETVAL;
+ return m;
fail:
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError,
"cannot load _operand_flag_tests module.");
}
-#if defined(NPY_PY3K)
if (m) {
Py_DECREF(m);
m = NULL;
}
-#endif
- return RETVAL;
-
+ return m;
}
diff --git a/numpy/core/src/umath/_rational_tests.c.src b/numpy/core/src/umath/_rational_tests.c.src
index 615e395c7..17fffdae2 100644
--- a/numpy/core/src/umath/_rational_tests.c.src
+++ b/numpy/core/src/umath/_rational_tests.c.src
@@ -1126,7 +1126,6 @@ PyMethodDef module_methods[] = {
{0} /* sentinel */
};
-#if defined(NPY_PY3K)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_rational_tests",
@@ -1138,16 +1137,8 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
-#if defined(NPY_PY3K)
-#define RETVAL m
PyMODINIT_FUNC PyInit__rational_tests(void) {
-#else
-#define RETVAL
-PyMODINIT_FUNC init_rational_tests(void) {
-#endif
-
PyObject *m = NULL;
PyObject* numpy_str;
PyObject* numpy;
@@ -1292,11 +1283,7 @@ PyMODINIT_FUNC init_rational_tests(void) {
REGISTER_UFUNC_UNARY(sign)
/* Create module */
-#if defined(NPY_PY3K)
m = PyModule_Create(&moduledef);
-#else
- m = Py_InitModule("_rational_tests", module_methods);
-#endif
if (!m) {
goto fail;
@@ -1392,18 +1379,16 @@ PyMODINIT_FUNC init_rational_tests(void) {
GCD_LCM_UFUNC(gcd,NPY_INT64,"greatest common denominator of two integers");
GCD_LCM_UFUNC(lcm,NPY_INT64,"least common multiple of two integers");
- return RETVAL;
+ return m;
fail:
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError,
"cannot load _rational_tests module.");
}
-#if defined(NPY_PY3K)
if (m) {
Py_DECREF(m);
m = NULL;
}
-#endif
- return RETVAL;
+ return m;
}
diff --git a/numpy/core/src/umath/_struct_ufunc_tests.c.src b/numpy/core/src/umath/_struct_ufunc_tests.c.src
index 3eaac73e1..1706dc829 100644
--- a/numpy/core/src/umath/_struct_ufunc_tests.c.src
+++ b/numpy/core/src/umath/_struct_ufunc_tests.c.src
@@ -100,7 +100,6 @@ static PyMethodDef StructUfuncTestMethods[] = {
{NULL, NULL, 0, NULL}
};
-#if defined(NPY_PY3K)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_struct_ufunc_tests",
@@ -112,31 +111,18 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
-#if defined(NPY_PY3K)
PyMODINIT_FUNC PyInit__struct_ufunc_tests(void)
-#else
-PyMODINIT_FUNC init_struct_ufunc_tests(void)
-#endif
{
PyObject *m, *add_triplet, *d;
PyObject *dtype_dict;
PyArray_Descr *dtype;
PyArray_Descr *dtypes[3];
-#if defined(NPY_PY3K)
m = PyModule_Create(&moduledef);
-#else
- m = Py_InitModule("_struct_ufunc_tests", StructUfuncTestMethods);
-#endif
if (m == NULL) {
-#if defined(NPY_PY3K)
return NULL;
-#else
- return;
-#endif
}
import_array();
@@ -166,7 +152,5 @@ PyMODINIT_FUNC init_struct_ufunc_tests(void)
PyDict_SetItemString(d, "add_triplet", add_triplet);
Py_DECREF(add_triplet);
-#if defined(NPY_PY3K)
return m;
-#endif
}
diff --git a/numpy/core/src/umath/_umath_tests.c.src b/numpy/core/src/umath/_umath_tests.c.src
index 6c3bcce71..bd3fe80b6 100644
--- a/numpy/core/src/umath/_umath_tests.c.src
+++ b/numpy/core/src/umath/_umath_tests.c.src
@@ -586,7 +586,6 @@ static PyMethodDef UMath_TestsMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
-#if defined(NPY_PY3K)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_umath_tests",
@@ -598,27 +597,16 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
/* Initialization function for the module */
-#if defined(NPY_PY3K)
-#define RETVAL(x) x
PyMODINIT_FUNC PyInit__umath_tests(void) {
-#else
-#define RETVAL(x)
-PyMODINIT_FUNC init_umath_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);
-#endif
if (m == NULL) {
- return RETVAL(NULL);
+ return NULL;
}
import_array();
@@ -636,8 +624,8 @@ PyMODINIT_FUNC init_umath_tests(void) {
PyErr_Print();
PyErr_SetString(PyExc_RuntimeError,
"cannot load _umath_tests module.");
- return RETVAL(NULL);
+ return NULL;
}
- return RETVAL(m);
+ return m;
}
diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py
index 28eb9da30..a147f94b4 100755
--- a/numpy/f2py/rules.py
+++ b/numpy/f2py/rules.py
@@ -194,13 +194,7 @@ static struct PyModuleDef moduledef = {
};
#endif
-#if PY_VERSION_HEX >= 0x03000000
-#define RETVAL m
PyMODINIT_FUNC PyInit_#modulename#(void) {
-#else
-#define RETVAL
-PyMODINIT_FUNC init#modulename#(void) {
-#endif
\tint i;
\tPyObject *m,*d, *s, *tmp;
#if PY_VERSION_HEX >= 0x03000000
@@ -211,7 +205,7 @@ PyMODINIT_FUNC init#modulename#(void) {
\tPy_TYPE(&PyFortran_Type) = &PyType_Type;
\timport_array();
\tif (PyErr_Occurred())
-\t\t{PyErr_SetString(PyExc_ImportError, \"can't initialize module #modulename# (failed to import numpy)\"); return RETVAL;}
+\t\t{PyErr_SetString(PyExc_ImportError, \"can't initialize module #modulename# (failed to import numpy)\"); return m;}
\td = PyModule_GetDict(m);
\ts = PyString_FromString(\"$R""" + """evision: $\");
\tPyDict_SetItemString(d, \"__version__\", s);
@@ -245,7 +239,7 @@ PyMODINIT_FUNC init#modulename#(void) {
\tif (! PyErr_Occurred())
\t\ton_exit(f2py_report_on_exit,(void*)\"#modulename#\");
#endif
-\treturn RETVAL;
+\treturn m;
}
#ifdef __cplusplus
}
diff --git a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c
index 978db4e69..369221c75 100644
--- a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c
+++ b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c
@@ -143,19 +143,9 @@ static struct PyModuleDef moduledef = {
};
#endif
-#if PY_VERSION_HEX >= 0x03000000
-#define RETVAL m
PyMODINIT_FUNC PyInit_test_array_from_pyobj_ext(void) {
-#else
-#define RETVAL
-PyMODINIT_FUNC inittest_array_from_pyobj_ext(void) {
-#endif
PyObject *m,*d, *s;
-#if PY_VERSION_HEX >= 0x03000000
m = wrap_module = PyModule_Create(&moduledef);
-#else
- m = wrap_module = Py_InitModule("test_array_from_pyobj_ext", f2py_module_methods);
-#endif
Py_TYPE(&PyFortran_Type) = &PyType_Type;
import_array();
if (PyErr_Occurred())
@@ -238,7 +228,7 @@ PyMODINIT_FUNC inittest_array_from_pyobj_ext(void) {
on_exit(f2py_report_on_exit,(void*)"array_from_pyobj.wrap.call");
#endif
- return RETVAL;
+ return m;
}
#ifdef __cplusplus
}
diff --git a/numpy/fft/_pocketfft.c b/numpy/fft/_pocketfft.c
index d75b9983c..de86e36d3 100644
--- a/numpy/fft/_pocketfft.c
+++ b/numpy/fft/_pocketfft.c
@@ -2359,7 +2359,6 @@ static struct PyMethodDef methods[] = {
{NULL, NULL, 0, NULL} /* sentinel */
};
-#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_pocketfft_internal",
@@ -2371,30 +2370,14 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
/* Initialization function for the module */
-#if PY_MAJOR_VERSION >= 3
-#define RETVAL(x) x
PyMODINIT_FUNC PyInit__pocketfft_internal(void)
-#else
-#define RETVAL(x)
-PyMODINIT_FUNC
-init_pocketfft_internal(void)
-#endif
{
PyObject *m;
-#if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&moduledef);
-#else
- static const char module_documentation[] = "";
-
- m = Py_InitModule4("_pocketfft_internal", methods,
- module_documentation,
- (PyObject*)NULL,PYTHON_API_VERSION);
-#endif
if (m == NULL) {
- return RETVAL(NULL);
+ return NULL;
}
/* Import the array object */
@@ -2402,5 +2385,5 @@ init_pocketfft_internal(void)
/* XXXX Add constants here */
- return RETVAL(m);
+ return m;
}
diff --git a/numpy/linalg/lapack_litemodule.c b/numpy/linalg/lapack_litemodule.c
index 56f38364f..362a593a6 100644
--- a/numpy/linalg/lapack_litemodule.c
+++ b/numpy/linalg/lapack_litemodule.c
@@ -377,7 +377,6 @@ static struct PyMethodDef lapack_lite_module_methods[] = {
};
-#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"lapack_lite",
@@ -389,27 +388,14 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
/* Initialization function for the module */
-#if PY_MAJOR_VERSION >= 3
-#define RETVAL(x) x
PyMODINIT_FUNC PyInit_lapack_lite(void)
-#else
-#define RETVAL(x)
-PyMODINIT_FUNC
-initlapack_lite(void)
-#endif
{
PyObject *m,*d;
-#if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&moduledef);
-#else
- m = Py_InitModule4("lapack_lite", lapack_lite_module_methods,
- "", (PyObject*)NULL,PYTHON_API_VERSION);
-#endif
if (m == NULL) {
- return RETVAL(NULL);
+ return NULL;
}
import_array();
d = PyModule_GetDict(m);
@@ -422,5 +408,5 @@ initlapack_lite(void)
PyDict_SetItemString(d, "_ilp64", Py_False);
#endif
- return RETVAL(m);
+ return m;
}
diff --git a/numpy/linalg/umath_linalg.c.src b/numpy/linalg/umath_linalg.c.src
index e864c541b..00ff6b7a8 100644
--- a/numpy/linalg/umath_linalg.c.src
+++ b/numpy/linalg/umath_linalg.c.src
@@ -3626,7 +3626,6 @@ static PyMethodDef UMath_LinAlgMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
-#if defined(NPY_PY3K)
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
UMATH_LINALG_MODULE_NAME,
@@ -3638,29 +3637,17 @@ static struct PyModuleDef moduledef = {
NULL,
NULL
};
-#endif
-#if defined(NPY_PY3K)
-#define RETVAL(x) x
PyObject *PyInit__umath_linalg(void)
-#else
-#define RETVAL(x)
-PyMODINIT_FUNC
-init_umath_linalg(void)
-#endif
{
PyObject *m;
PyObject *d;
PyObject *version;
init_constants();
-#if defined(NPY_PY3K)
m = PyModule_Create(&moduledef);
-#else
- m = Py_InitModule(UMATH_LINALG_MODULE_NAME, UMath_LinAlgMethods);
-#endif
if (m == NULL) {
- return RETVAL(NULL);
+ return NULL;
}
import_array();
@@ -3678,8 +3665,8 @@ init_umath_linalg(void)
if (PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError,
"cannot load _umath_linalg module.");
- return RETVAL(NULL);
+ return NULL;
}
- return RETVAL(m);
+ return m;
}