8000 Remove Python2 module setup code · numpy/numpy@6a1f513 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a1f513

Browse files
committed
Remove Python2 module setup code
1 parent cf40ad9 commit 6a1f513

14 files changed

+13
-122
lines changed

doc/Py3K.rst.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ A #define in config.h, defined when building for Py3.
225225
Currently, this is generated as a part of the config.
226226
Is this sensible (we could also use Py_VERSION_HEX)?
227227

228+
This is being cleaned up in the C code.
229+
228230

229231
private/npy_3kcompat.h
230232
----------------------

doc/source/user/c-info.ufunc-tutorial.rst

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,6 @@ The C file is given below.
976976
977977
static void *data[1] = {NULL};
978978
979-
#if defined(NPY_PY3K)
980979
static struct PyModuleDef moduledef = {
981980
PyModuleDef_HEAD_INIT,
982981
"struct_ufunc_test",
@@ -988,31 +987,18 @@ The C file is given below.
988987
NULL,
989988
NULL
990989
};
991-
#endif
992990
993-
#if defined(NPY_PY3K)
994991
PyMODINIT_FUNC PyInit_struct_ufunc_test(void)
995-
#else
996-
PyMODINIT_FUNC initstruct_ufunc_test(void)
997-
#endif
998992
{
999993
PyObject *m, *add_triplet, *d;
1000994
PyObject *dtype_dict;
1001995
PyArray_Descr *dtype;
1002996
PyArray_Descr *dtypes[3];
1003997
1004-
#if defined(NPY_PY3K)
1005998
m = PyModule_Create(&moduledef);
1006-
#else
1007-
m = Py_InitModule("struct_ufunc_test", StructUfuncTestMethods);
1008-
#endif
1009999
10101000
if (m == NULL) {
1011-
#if defined(NPY_PY3K)
10121001
return NULL;
1013-
#else
1014-
return;
1015-
#endif
10161002
}
10171003
10181004
import_array();
@@ -1043,9 +1029,7 @@ The C file is given below.
10431029
10441030
PyDict_SetItemString(d, "add_triplet", add_triplet);
10451031
Py_DECREF(add_triplet);
1046-
#if defined(NPY_PY3K)
10471032
return m;
1048-
#endif
10491033
}
10501034
10511035
.. index::

numpy/core/src/dummymodule.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ static struct PyMethodDef methods[] = {
1616
};
1717

1818

19-
#if defined(NPY_PY3K)
2019
static struct PyModuleDef moduledef = {
2120
PyModuleDef_HEAD_INIT,
2221
"dummy",
@@ -28,10 +27,8 @@ static struct PyModuleDef moduledef = {
2827
NULL,
2928
NULL
3029
};
31-
#endif
3230

3331
/* Initialization function for the module */
34-
#if defined(NPY_PY3K)
3532
PyMODINIT_FUNC PyInit__dummy(void) {
3633
PyObject *m;
3734
m = PyModule_Create(&moduledef);
@@ -40,9 +37,3 @@ PyMODINIT_FUNC PyInit__dummy(void) {
4037
}
4138
return m;
4239
}
43-
#else
44-
PyMODINIT_FUNC
45-
init_dummy(void) {
46-
Py_InitModule("_dummy", methods);
47-
}
48-
#endif

numpy/core/src/multiarray/_multiarray_tests.c.src

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,6 @@ static PyMethodDef Multiarray_TestsMethods[] = {
21262126
};
21272127

21282128

2129-
#if defined(NPY_PY3K)
21302129
static struct PyModuleDef moduledef = {
21312130
PyModuleDef_HEAD_INIT,
21322131
"_multiarray_tests",
@@ -2138,24 +2137,13 @@ static struct PyModuleDef moduledef = {
21382137
NULL,
21392138
NULL
21402139
};
2141-
#endif
21422140

2143-
#if defined(NPY_PY3K)
21442141
#define RETVAL m
21452142
PyMODINIT_FUNC PyInit__multiarray_tests(void)
2146-
#else
2147-
#define RETVAL
2148-
PyMODINIT_FUNC
2149-
init_multiarray_tests(void)
2150-
#endif
21512143
{
21522144
PyObject *m;
21532145

2154-
#if defined(NPY_PY3K)
21552146
m = PyModule_Create(&moduledef);
2156-
#else
2157-
m = Py_InitModule("_multiarray_tests", Multiarray_TestsMethods);
2158-
#endif
21592147
if (m == NULL) {
21602148
return RETVAL;
21612149
}

numpy/core/src/multiarray/arraytypes.c.src

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ _setup_field(int i, PyArray_Descr *descr, PyArrayObject *arr,
748748
}
749749

750750
((PyArrayObject_fields *)(arr))->descr = new;
751-
if ((new->alignment > 1) &&
751+
if ((new->alignment > 1) &&
752752
((((uintptr_t)dstdata + offset) % new->alignment) != 0)) {
753753
PyArray_CLEARFLAGS(arr, NPY_ARRAY_ALIGNED);
754754
}
@@ -836,7 +836,7 @@ VOID_setitem(PyObject *op, void *input, void *vap)
836836
if (names_size != PyTuple_Size(op)) {
837837
errmsg = PyUString_FromFormat(
838838
"could not assign tuple of length %zd to structure "
839-
"with %" NPY_INTP_FMT " fields.",
839+
"with %" NPY_INTP_FMT " fields.",
840840
PyTuple_Size(op), names_size);
841841
PyErr_SetObject(PyExc_ValueError, errmsg);
842842
Py_DECREF(errmsg);
@@ -3000,7 +3000,7 @@ OBJECT_compare(PyObject **ip1, PyObject **ip2, PyArrayObject *NPY_UNUSED(ap))
30003000

30013001
ret = PyObject_RichCompareBool(*ip1, *ip2, Py_LT);
30023002
if (ret < 0) {
3003-
/* error occurred, avoid the next call to PyObject_RichCompareBool */
3003+
/* error occurred, avoid the next call to PyObject_RichCompareBool */
30043004
return 0;
30053005
}
30063006
if (ret == 1) {
@@ -4429,7 +4429,7 @@ static PyArray_ArrFuncs _Py@NAME@_ArrFuncs = {
44294429
#if @rsort@
44304430
aradixsort_@suff@
44314431
#else
4432-
atimsort_@suff@
4432+
atimsort_@suff@
44334433
#endif
44344434
},
44354435
#else

numpy/core/src/multiarray/compiled_base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ arr_ravel_multi_index(PyObject *self, PyObject *args, PyObject *kwds)
11591159
}
11601160

11611161

1162-
/*
1162+
/*
11631163
* Inner loop for unravel_index
11641164
* order must be NPY_CORDER or NPY_FORTRANORDER
11651165
*/
@@ -1186,7 +1186,7 @@ unravel_index_loop(int unravel_ndim, npy_intp *unravel_dims,
11861186
}
11871187
idx = idx_start;
11881188
for (i = 0; i < unravel_ndim; ++i) {
1189-
/*
1189+
/*
11901190
* Using a local seems to enable single-divide optimization
11911191
* but only if the / precedes the %
11921192
*/

numpy/core/src/multiarray/descriptor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ _convert_from_tuple(PyObject *obj, int align)
241241
if (!PyArray_DescrConverter(PyTuple_GET_ITEM(obj, 0), &type)) {
242242
return NULL;
243243
}
244-
}
244+
}
245245
val = PyTuple_GET_ITEM(obj,1);
246246
/* try to interpret next item as a type */
247247
res = _use_inherit(type, val, &errflag);
@@ -455,11 +455,11 @@ _convert_from_array_descr(PyObject *obj, int align)
455455
Py_INCREF(name);
456456

457457
#if !defined(NPY_PY3K)
458-
/* convert unicode name to ascii on Python 2 if possible */
458+
/* convert unicode name to ascii on Python 2 if possible */
459459
if (PyUnicode_Check(name)) {
460460
PyObject *tmp = PyUnicode_AsASCIIString(name);
461461
Py_DECREF(name);
462-
if (tmp == NULL) {
462+
if (tmp == NULL) {
463463
goto fail;
464464
}
465465
name = tmp;

numpy/core/src/multiarray/item_selection.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,7 @@ PyArray_Nonzero(PyArrayObject *self)
23922392
Py_DECREF(ret);
23932393
return NULL;
23942394
}
2395-
2395+
23962396
needs_api = NpyIter_IterationNeedsAPI(iter);
23972397

23982398
NPY_BEGIN_THREADS_NDITER(iter);
@@ -2436,7 +2436,7 @@ PyArray_Nonzero(PyArrayObject *self)
24362436
Py_DECREF(ret);
24372437
return NULL;
24382438
}
2439-
2439+
24402440
/* if executed `nonzero()` check for miscount due to side-effect */
24412441
if (!is_bool && added_count != nonzero_count) {
24422442
PyErr_SetString(PyExc_RuntimeError,

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,7 +4551,6 @@ intern_strings(void)
45514551
npy_ma_str_ndmin && npy_ma_str_axis1 && npy_ma_str_axis2;
45524552
}
45534553

4554-
#if defined(NPY_PY3K)
45554554
static struct PyModuleDef moduledef = {
45564555
PyModuleDef_HEAD_INIT,
45574556
"_multiarray_umath",
@@ -4563,25 +4562,15 @@ static struct PyModuleDef moduledef = {
45634562
NULL,
45644563
NULL
45654564
};
4566-
#endif
45674565

45684566
/* Initialization function for the module */
4569-
#if defined(NPY_PY3K)
45704567
#define RETVAL(x) x
45714568
PyMODINIT_FUNC PyInit__multiarray_umath(void) {
4572-
#else
4573-
#define RETVAL(x)
4574-
PyMODINIT_FUNC init_multiarray_umath(void) {
4575-
#endif
45764569
PyObject *m, *d, *s;
45774570
PyObject *c_api;
45784571

45794572
/* Create the module and add the functions */
4580-
#if defined(NPY_PY3K)
45814573
m = PyModule_Create(&moduledef);
4582-
#else
4583-
m = Py_InitModule("_multiarray_umath", array_module_methods);
4584-
#endif
45854574
if (!m) {
45864575
goto err;
45874576
}

numpy/core/src/umath/_operand_flag_tests.c.src

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ static char types[2] = {NPY_LONG, NPY_LONG};
3939

4040
static void *data[1] = {NULL};
4141

42-
#if defined(NPY_PY3K)
4342
static struct PyModuleDef moduledef = {
4443
PyModuleDef_HEAD_INIT,
4544
"_operand_flag_tests",
@@ -55,19 +54,10 @@ static struct PyModuleDef moduledef = {
5554
#define RETVAL m
5655
PyMODINIT_FUNC PyInit__operand_flag_tests(void)
5756
{
58-
#else
59-
#define RETVAL
60-
PyMODINIT_FUNC init_operand_flag_tests(void)
61-
{
62-
#endif
6357
PyObject *m = NULL;
6458
PyObject *ufunc;
6559

66-
#if defined(NPY_PY3K)
6760
m = PyModule_Create(&moduledef);
68-
#else
69-
m = Py_InitModule("_operand_flag_tests", TestMethods);
70-
#endif
7161
if (m == NULL) {
7262
goto fail;
7363
}

0 commit comments

Comments
 (0)
0