8000 MAINT: Remove compatibility shims for old versions of PyPy · rjeb/numpy@b456bb6 · GitHub
[go: up one dir, main page]

Skip to content

Commit b456bb6

Browse files
committed
MAINT: Remove compatibility shims for old versions of PyPy
It seems that the newest of these targeted versions of 7.3.5 and older. But these versions (as far as I can tell) did not even ship Python 3.8 and thus should not be compatible in any case.
1 parent 7e15fd7 commit b456bb6

File tree

5 files changed

+2
-69
lines changed

5 files changed

+2
-69
lines changed

numpy/core/src/multiarray/alloc.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,7 @@ PyDataMem_Handler default_handler = {
424424
};
425425
/* singleton capsule of the default handler */
426426
PyObject *PyDataMem_DefaultHandler;
427-
428-
#if (!defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM >= 0x07030600)
429427
PyObject *current_handler;
430-
#endif
431428

432429
int uo_index=0; /* user_override index */
433430

@@ -539,7 +536,6 @@ NPY_NO_EXPORT PyObject *
539536
PyDataMem_SetHandler(PyObject *handler)
540537
{
541538
PyObject *old_handler;
542-
#if (!defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM >= 0x07030600)
543539
PyObject *token;
544540
if (PyContextVar_Get(current_handler, NULL, &old_handler)) {
545541
return NULL;
@@ -554,27 +550,6 @@ PyDataMem_SetHandler(PyObject *handler)
554550
}
555551
Py_DECREF(token);
556552
return old_handler;
557-
#else
558-
PyObject *p;
559-
p = PyThreadState_GetDict();
560-
if (p == NULL) {
561-
return NULL;
562-
}
563-
old_handler = PyDict_GetItemString(p, "current_allocator");
564-
if (old_handler == NULL) {
565-
old_handler = PyDataMem_DefaultHandler
566-
}
567-
Py_INCREF(old_handler);
568-
if (handler == NULL) {
569-
handler = PyDataMem_DefaultHandler;
570-
}
571-
const int error = PyDict_SetItemString(p, "current_allocator", handler);
572-
if (error) {
573-
Py_DECREF(old_handler);
574-
return NULL;
575-
}
576-
return old_handler;
577-
#endif
578553
}
579554

580555
/*NUMPY_API
@@ -585,28 +560,10 @@ NPY_NO_EXPORT PyObject *
585560
PyDataMem_GetHandler()
586561
{
587562
PyObject *handler;
588-
#if (!defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM >= 0x07030600)
589563
if (PyContextVar_Get(current_handler, NULL, &handler)) {
590564
return NULL;
591565
}
592566
return handler;
593-
#else
594-
PyObject *p = PyThreadState_GetDict();
595-
if (p == NULL) {
596-
return NULL;
597-
}
598-
handler = PyDict_GetItem(p, npy_ma_str_current_allocator);
599-
if (handler == NULL) {
600-
handler = PyCapsule_New(&default_handler, "mem_handler", NULL);
601-
if (handler == NULL) {
602-
return NULL;
603-
}
604-
}
605-
else {
606-
Py_INCREF(handler);
607-
}
608-
return handler;
609-
#endif
610567
}
611568

612569
NPY_NO_EXPORT PyObject *

numpy/core/src/multiarray/alloc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ npy_free_cache_dim_array(PyArrayObject * arr)
4444
}
4545

4646
extern PyDataMem_Handler default_handler;
47-
#if (!defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM >= 0x07030600)
4847
extern PyObject *current_handler; /* PyContextVar/PyCapsule */
49-
#endif
5048

5149
NPY_NO_EXPORT PyObject *
5250
get_handler_name(PyObject *NPY_UNUSED(self), PyObject *obj);

numpy/core/src/multiarray/compiled_base.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,11 +1393,7 @@ arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *args)
13931393
{
13941394
PyObject *obj;
13951395
PyObject *str;
1396-
#if !defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM > 0x07030300
13971396
const char *docstr;
1398-
#else
1399-
char *docstr;
1400-
#endif
14011397
static char *msg = "already has a different docstring";
14021398

14031399
/* Don't add docstrings */

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4997,16 +4997,15 @@ PyMODINIT_FUNC PyInit__multiarray_umath(void) {
49974997
if (PyDataMem_DefaultHandler == NULL) {
49984998
goto err;
49994999
}
5000-
#if (!defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM >= 0x07030600)
50015000
/*
50025001
* Initialize the context-local current handler
50035002
* with the default PyDataMem_Handler capsule.
5004-
*/
5003+
*/
50055004
current_handler = PyContextVar_New("current_allocator", PyDataMem_DefaultHandler);
50065005
if (current_handler == NULL) {
50075006
goto err;
50085007
}
5009-
#endif
5008+
50105009
return m;
50115010

50125011
err:

numpy/core/src/multiarray/typeinfo.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
#include "npy_pycompat.h"
1010
#include "typeinfo.h"
1111

12-
#if (defined(PYPY_VERSION_NUM) && (PYPY_VERSION_NUM <= 0x07030000))
13-
/* PyPy issue 3160 */
14-
#include <structseq.h>
15-
#endif
16-
17-
1812

1913
static PyTypeObject PyArray_typeinfoType;
2014
static PyTypeObject PyArray_typeinforangedType;
@@ -99,17 +93,6 @@ PyArray_typeinforanged(
9993
return entry;
10094
}
10195

102-
/* Python version needed for older PyPy */
103-
#if (defined(PYPY_VERSION_NUM) && (PYPY_VERSION_NUM < 0x07020000))
104-
static int
105-
PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc) {
106-
PyStructSequence_InitType(type, desc);
107-
if (PyErr_Occurred()) {
108-
return -1;
109-
}
110-
return 0;
111-
}
112-
#endif
11396

11497
NPY_NO_EXPORT int
11598
typeinfo_init_structsequences(PyObject *multiarray_dict)

0 commit comments

Comments
 (0)
0