Skip to content

Commit 213304c

Browse files
committed
Fix patch for numpy==1.23.1
1 parent ca379fb commit 213304c

File tree

2 files changed

+132
-119
lines changed

2 files changed

+132
-119
lines changed

graalpython/lib-graalpython/patches/numpy/metadata.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ patch = 'numpy-1.22.4.patch'
1818
version = '== 1.23.4'
1919
patch = 'numpy-1.23.4.patch'
2020

21+
[[rules]]
22+
version = '== 1.23.1'
23+
patch = 'numpy-1.23.1.patch'
24+
2125
[[rules]]
2226
# pin 1.23.5
2327
install-priority = 10

graalpython/lib-graalpython/patches/numpy/numpy-1.23.1.patch

Lines changed: 128 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
diff -u -r a/numpy/core/src/_simd/_simd_convert.inc b/numpy/core/src/_simd/_simd_convert.inc
2-
--- a/numpy/core/src/_simd/_simd_convert.inc 2022-10-10 13:53:09.000000000 +0200
3-
+++ b/numpy/core/src/_simd/_simd_convert.inc 2022-10-10 13:53:08.000000000 +0200
4-
@@ -101,9 +101,8 @@
1+
diff --git a/numpy/core/src/_simd/_simd_convert.inc b/numpy/core/src/_simd/_simd_convert.inc
2+
index 46e0444..261cf5b 100644
3+
--- a/numpy/core/src/_simd/_simd_convert.inc
4+
+++ b/numpy/core/src/_simd/_simd_convert.inc
5+
@@ -101,9 +101,8 @@ simd_sequence_from_iterable(PyObject *obj, simd_data_type dtype, Py_ssize_t min_
56
if (dst == NULL) {
67
return NULL;
78
}
@@ -12,10 +13,11 @@ diff -u -r a/numpy/core/src/_simd/_simd_convert.inc b/numpy/core/src/_simd/_simd
1213
npyv_lanetype_u8 *sdst = dst + i * info->lane_size;
1314
memcpy(sdst, &data.u64, info->lane_size);
1415
}
15-
diff -u -r a/numpy/core/src/common/ufunc_override.c b/numpy/core/src/common/ufunc_override.c
16-
--- a/numpy/core/src/common/ufunc_override.c 2022-10-10 13:53:09.000000000 +0200
17-
+++ b/numpy/core/src/common/ufunc_override.c 2022-10-10 13:53:08.000000000 +0200
18-
@@ -79,13 +79,12 @@
16+
diff --git a/numpy/core/src/common/ufunc_override.c b/numpy/core/src/common/ufunc_override.c
17+
index 4fb4d4b..06552f0 100644
18+
--- a/numpy/core/src/common/ufunc_override.c
19+
+++ b/numpy/core/src/common/ufunc_override.c
20+
@@ -79,13 +79,12 @@ PyUFunc_HasOverride(PyObject * obj)
1921
/*
2022
* Get possible out argument from kwds, and returns the number of outputs
2123
* contained within it: if a tuple, the number of elements in it, 1 otherwise.
@@ -31,7 +33,7 @@ diff -u -r a/numpy/core/src/common/ufunc_override.c b/numpy/core/src/common/ufun
3133
{
3234
if (kwds == NULL) {
3335
Py_INCREF(Py_None);
34-
@@ -121,13 +120,11 @@
36+
@@ -121,13 +120,11 @@ PyUFuncOverride_GetOutObjects(PyObject *kwds, PyObject **out_kwd_obj, PyObject *
3537
*out_kwd_obj = NULL;
3638
return -1;
3739
}
@@ -46,10 +48,11 @@ diff -u -r a/numpy/core/src/common/ufunc_override.c b/numpy/core/src/common/ufun
4648
return 1;
4749
}
4850
}
49-
diff -u -r a/numpy/core/src/common/ufunc_override.h b/numpy/core/src/common/ufunc_override.h
50-
--- a/numpy/core/src/common/ufunc_override.h 2022-10-10 13:53:09.000000000 +0200
51-
+++ b/numpy/core/src/common/ufunc_override.h 2022-10-10 13:53:08.000000000 +0200
52-
@@ -27,12 +27,11 @@
51+
diff --git a/numpy/core/src/common/ufunc_override.h b/numpy/core/src/common/ufunc_override.h
52+
index 5da95fb..3879016 100644
53+
--- a/numpy/core/src/common/ufunc_override.h
54+
+++ b/numpy/core/src/common/ufunc_override.h
55+
@@ -27,12 +27,11 @@ PyUFunc_HasOverride(PyObject *obj);
5356
/*
5457
* Get possible out argument from kwds, and returns the number of outputs
5558
* contained within it: if a tuple, the number of elements in it, 1 otherwise.
@@ -64,18 +67,19 @@ diff -u -r a/numpy/core/src/common/ufunc_override.h b/numpy/core/src/common/ufun
6467
+PyUFuncOverride_GetOutObjects(PyObject *kwds, PyObject **out_kwd_obj);
6568

6669
#endif /* NUMPY_CORE_SRC_COMMON_UFUNC_OVERRIDE_H_ */
67-
diff -u -r a/numpy/core/src/multiarray/array_coercion.c b/numpy/core/src/multiarray/array_coercion.c
68-
--- a/numpy/core/src/multiarray/array_coercion.c 2022-10-10 13:53:09.000000000 +0200
69-
+++ b/numpy/core/src/multiarray/array_coercion.c 2022-10-10 13:53:08.000000000 +0200
70-
@@ -1106,7 +1106,6 @@
70+
diff --git a/numpy/core/src/multiarray/array_coercion.c b/numpy/core/src/multiarray/array_coercion.c
71+
index 562e4f0..1ed009b 100644
72+
--- a/numpy/core/src/multiarray/array_coercion.c
73+
+++ b/numpy/core/src/multiarray/array_coercion.c
74+
@@ -1106,7 +1106,6 @@ PyArray_DiscoverDTypeAndShape_Recursive(
7175
}
7276

7377
npy_intp size = PySequence_Fast_GET_SIZE(seq);
7478
- PyObject **objects = PySequence_Fast_ITEMS(seq);
7579

7680
if (update_shape(curr_dims, &max_dims,
7781
out_shape, 1, &size, NPY_TRUE, flags) < 0) {
78-
@@ -1128,7 +1127,7 @@
82+
@@ -1128,7 +1127,7 @@ PyArray_DiscoverDTypeAndShape_Recursive(
7983
/* Recursive call for each sequence item */
8084
for (Py_ssize_t i = 0; i < size; i++) {
8185
max_dims = PyArray_DiscoverDTypeAndShape_Recursive(
@@ -84,10 +88,11 @@ diff -u -r a/numpy/core/src/multiarray/array_coercion.c b/numpy/core/src/multiar
8488
out_descr, out_shape, coercion_cache_tail_ptr, fixed_DType,
8589
flags, never_copy);
8690

87-
diff -u -r a/numpy/core/src/multiarray/arrayfunction_override.c b/numpy/core/src/multiarray/arrayfunction_override.c
88-
--- a/numpy/core/src/multiarray/arrayfunction_override.c 2022-10-10 13:53:09.000000000 +0200
89-
+++ b/numpy/core/src/multiarray/arrayfunction_override.c 2022-10-10 13:53:08.000000000 +0200
90-
@@ -72,12 +72,11 @@
91+
diff --git a/numpy/core/src/multiarray/arrayfunction_override.c b/numpy/core/src/multiarray/arrayfunction_override.c
92+
index af53d78..1fcd6d3 100644
93+
--- a/numpy/core/src/multiarray/arrayfunction_override.c
94+
+++ b/numpy/core/src/multiarray/arrayfunction_override.c
95+
@@ -72,12 +72,11 @@ get_implementing_args_and_methods(PyObject *relevant_args,
9196
{
9297
int num_implementing_args = 0;
9398

@@ -101,7 +106,7 @@ diff -u -r a/numpy/core/src/multiarray/arrayfunction_override.c b/numpy/core/src
101106

102107
/* Have we seen this type before? */
103108
for (int j = 0; j < num_implementing_args; j++) {
104-
@@ -156,12 +155,11 @@
109+
@@ -156,12 +155,11 @@ NPY_NO_EXPORT PyObject *
105110
array_function_method_impl(PyObject *func, PyObject *types, PyObject *args,
106111
PyObject *kwargs)
107112
{
@@ -115,10 +120,11 @@ diff -u -r a/numpy/core/src/multiarray/arrayfunction_override.c b/numpy/core/src
115120
if (is_subclass == -1) {
116121
return NULL;
117122
}
118-
diff -u -r a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c
119-
--- a/numpy/core/src/multiarray/compiled_base.c 2022-10-10 13:53:09.000000000 +0200
120-
+++ b/numpy/core/src/multiarray/compiled_base.c 2022-10-10 13:53:08.000000000 +0200
121-
@@ -1414,78 +1414,78 @@
123+
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c
124+
index 2b82aca..7260b1b 100644
125+
--- a/numpy/core/src/multiarray/compiled_base.c
126+
+++ b/numpy/core/src/multiarray/compiled_base.c
127+
@@ -1414,78 +1414,78 @@ arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *args)
122128
return NULL;
123129
}
124130

@@ -134,7 +140,7 @@ diff -u -r a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarr
134140
-
135141
- if (Py_TYPE(obj) == &PyCFunction_Type) {
136142
- PyCFunctionObject *new = (PyCFunctionObject *)obj;
137-
- _ADDDOC(new->m_ml->ml_doc, new->m_ml->ml_name);
143+
- _ADDDOC(PyObject_GetDoc((PyObject*)(new)), new->m_ml->ml_name);
138144
- }
139145
- else if (PyObject_TypeCheck(obj, &PyType_Type)) {
140146
- /*
@@ -194,85 +200,86 @@ diff -u -r a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarr
194200
- }
195201
-
196202
-#undef _ADDDOC
197-
+//#define _ADDDOC(doc, name) \
198-
+// if (!(doc)) { \
199-
+// doc = docstr; \
200-
+// Py_INCREF(str); /* hold on to string (leaks reference) */ \
201-
+// } \
202-
+// else if (strcmp(doc, docstr) != 0) { \
203-
+// PyErr_Format(PyExc_RuntimeError, "%s method %s", name, msg); \
204-
+// return NULL; \
205-
+// }
206-
+//
207-
+// if (Py_TYPE(obj) == &PyCFunction_Type) {
208-
+// PyCFunctionObject *new = (PyCFunctionObject *)obj;
209-
+// _ADDDOC(new->m_ml->ml_doc, new->m_ml->ml_name);
210-
+// }
211-
+// else if (PyObject_TypeCheck(obj, &PyType_Type)) {
212-
+// /*
213-
+// * We add it to both `tp_doc` and `__doc__` here. Note that in theory
214-
+// * `tp_doc` extracts the signature line, but we currently do not use
215-
+// * it. It may make sense to only add it as `__doc__` and
216-
+// * `__text_signature__` to the dict in the future.
217-
+// * The dictionary path is only necessary for heaptypes (currently not
218-
+// * used) and metaclasses.
219-
+// * If `__doc__` as stored in `tp_dict` is None, we assume this was
220-
+// * filled in by `PyType_Ready()` and should also be replaced.
221-
+// */
222-
+// PyTypeObject *new = (PyTypeObject *)obj;
223-
+// _ADDDOC(new->tp_doc, new->tp_name);
224-
+// if (new->tp_dict != NULL && PyDict_CheckExact(new->tp_dict) &&
225-
+// PyDict_GetItemString(new->tp_dict, "__doc__") == Py_None) {
226-
+// /* Warning: Modifying `tp_dict` is not generally safe! */
227-
+// if (PyDict_SetItemString(new->tp_dict, "__doc__", str) < 0) {
228-
+// return NULL;
229-
+// }
230-
+// }
231-
+// }
232-
+// else if (Py_TYPE(obj) == &PyMemberDescr_Type) {
233-
+// PyMemberDescrObject *new = (PyMemberDescrObject *)obj;
234-
+// _ADDDOC(new->d_member->doc, new->d_member->name);
235-
+// }
236-
+// else if (Py_TYPE(obj) == &PyGetSetDescr_Type) {
237-
+// PyGetSetDescrObject *new = (PyGetSetDescrObject *)obj;
238-
+// _ADDDOC(new->d_getset->doc, new->d_getset->name);
239-
+// }
240-
+// else if (Py_TYPE(obj) == &PyMethodDescr_Type) {
241-
+// PyMethodDescrObject *new = (PyMethodDescrObject *)obj;
242-
+// _ADDDOC(new->d_method->ml_doc, new->d_method->ml_name);
243-
+// }
244-
+// else {
245-
+// PyObject *doc_attr;
246-
+//
247-
+// doc_attr = PyObject_GetAttrString(obj, "__doc__");
248-
+// if (doc_attr != NULL && doc_attr != Py_None &&
249-
+// (PyUnicode_Compare(doc_attr, str) != 0)) {
250-
+// Py_DECREF(doc_attr);
251-
+// if (PyErr_Occurred()) {
252-
+// /* error during PyUnicode_Compare */
253-
+// return NULL;
254-
+// }
255-
+// PyErr_Format(PyExc_RuntimeError, "object %s", msg);
256-
+// return NULL;
257-
+// }
258-
+// Py_XDECREF(doc_attr);
259-
+//
260-
+// if (PyObject_SetAttrString(obj, "__doc__", str) < 0) {
261-
+// PyErr_SetString(PyExc_TypeError,
262-
+// "Cannot set a docstring for that object");
263-
+// return NULL;
264-
+// }
265-
+// Py_RETURN_NONE;
266-
+// }
267-
+//
268-
+//#undef _ADDDOC
203+
+// #define _ADDDOC(doc, name) \
204+
+// if (!(doc)) { \
205+
+// doc = docstr; \
206+
+// Py_INCREF(str); /* hold on to string (leaks reference) */ \
207+
+// } \
208+
+// else if (strcmp(doc, docstr) != 0) { \
209+
+// PyErr_Format(PyExc_RuntimeError, "%s method %s", name, msg); \
210+
+// return NULL; \
211+
+// }
212+
+//
213+
+// if (Py_TYPE(obj) == &PyCFunction_Type) {
214+
+// PyCFunctionObject *new = (PyCFunctionObject *)obj;
215+
+// _ADDDOC(PyObject_GetDoc((PyObject*)(new)), new->m_ml->ml_name);
216+
+// }
217+
+// else if (PyObject_TypeCheck(obj, &PyType_Type)) {
218+
+// /*
219+
+// * We add it to both `tp_doc` and `__doc__` here. Note that in theory
220+
+// * `tp_doc` extracts the signature line, but we currently do not use
221+
+// * it. It may make sense to only add it as `__doc__` and
222+
+// * `__text_signature__` to the dict in the future.
223+
+// * The dictionary path is only necessary for heaptypes (currently not
224+
+// * used) and metaclasses.
225+
+// * If `__doc__` as stored in `tp_dict` is None, we assume this was
226+
+// * filled in by `PyType_Ready()` and should also be replaced.
227+
+// */
228+
+// PyTypeObject *new = (PyTypeObject *)obj;
229+
+// _ADDDOC(new->tp_doc, new->tp_name);
230+
+// if (new->tp_dict != NULL && PyDict_CheckExact(new->tp_dict) &&
231+
+// PyDict_GetItemString(new->tp_dict, "__doc__") == Py_None) {
232+
+// /* Warning: Modifying `tp_dict` is not generally safe! */
233+
+// if (PyDict_SetItemString(new->tp_dict, "__doc__", str) < 0) {
234+
+// return NULL;
235+
+// }
236+
+// }
237+
+// }
238+
+// else if (Py_TYPE(obj) == &PyMemberDescr_Type) {
239+
+// PyMemberDescrObject *new = (PyMemberDescrObject *)obj;
240+
+// _ADDDOC(new->d_member->doc, new->d_member->name);
241+
+// }
242+
+// else if (Py_TYPE(obj) == &PyGetSetDescr_Type) {
243+
+// PyGetSetDescrObject *new = (PyGetSetDescrObject *)obj;
244+
+// _ADDDOC(new->d_getset->doc, new->d_getset->name);
245+
+// }
246+
+// else if (Py_TYPE(obj) == &PyMethodDescr_Type) {
247+
+// PyMethodDescrObject *new = (PyMethodDescrObject *)obj;
248+
+// _ADDDOC(new->d_method->ml_doc, new->d_method->ml_name);
249+
+// }
250+
+// else {
251+
+// PyObject *doc_attr;
252+
+//
253+
+// doc_attr = PyObject_GetAttrString(obj, "__doc__");
254+
+// if (doc_attr != NULL && doc_attr != Py_None &&
255+
+// (PyUnicode_Compare(doc_attr, str) != 0)) {
256+
+// Py_DECREF(doc_attr);
257+
+// if (PyErr_Occurred()) {
258+
+// /* error during PyUnicode_Compare */
259+
+// return NULL;
260+
+// }
261+
+// PyErr_Format(PyExc_RuntimeError, "object %s", msg);
262+
+// return NULL;
263+
+// }
264+
+// Py_XDECREF(doc_attr);
265+
+//
266+
+// if (PyObject_SetAttrString(obj, "__doc__", str) < 0) {
267+
+// PyErr_SetString(PyExc_TypeError,
268+
+// "Cannot set a docstring for that object");
269+
+// return NULL;
270+
+// }
271+
+// Py_RETURN_NONE;
272+
+// }
273+
+//
274+
+// #undef _ADDDOC
269275

270276
Py_RETURN_NONE;
271277
}
272-
diff -u -r a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/iterators.c
273-
--- a/numpy/core/src/multiarray/iterators.c 2022-10-10 13:53:09.000000000 +0200
274-
+++ b/numpy/core/src/multiarray/iterators.c 2022-10-10 13:53:08.000000000 +0200
275-
@@ -1400,7 +1400,11 @@
278+
diff --git a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/iterators.c
279+
index f959162..2ef579b 100644
280+
--- a/numpy/core/src/multiarray/iterators.c
281+
+++ b/numpy/core/src/multiarray/iterators.c
282+
@@ -1400,7 +1400,11 @@ arraymultiter_new(PyTypeObject *NPY_UNUSED(subtype), PyObject *args,
276283
Py_DECREF(fast_seq);
277284
return multiiter_wrong_number_of_args();
278285
}
@@ -285,18 +292,19 @@ diff -u -r a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/i
285292
Py_DECREF(fast_seq);
286293
return ret;
287294
}
288-
diff -u -r a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
289-
--- a/numpy/core/src/multiarray/methods.c 2022-10-10 13:53:09.000000000 +0200
290-
+++ b/numpy/core/src/multiarray/methods.c 2022-10-10 13:53:08.000000000 +0200
291-
@@ -1095,7 +1095,6 @@
295+
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
296+
index 161dca1..bedca0c 100644
297+
--- a/numpy/core/src/multiarray/methods.c
298+
+++ b/numpy/core/src/multiarray/methods.c
299+
@@ -1095,7 +1095,6 @@ any_array_ufunc_overrides(PyObject *args, PyObject *kwds)
292300
int nin, nout;
293301
PyObject *out_kwd_obj;
294302
PyObject *fast;
295303
- PyObject **in_objs, **out_objs;
296304

297305
/* check inputs */
298306
nin = PyTuple_Size(args);
299-
@@ -1106,21 +1105,20 @@
307+
@@ -1106,21 +1105,20 @@ any_array_ufunc_overrides(PyObject *args, PyObject *kwds)
300308
if (fast == NULL) {
301309
return -1;
302310
}
@@ -321,10 +329,11 @@ diff -u -r a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/met
321329
Py_DECREF(out_kwd_obj);
322330
return 1;
323331
}
324-
diff -u -r a/numpy/core/src/umath/extobj.c b/numpy/core/src/umath/extobj.c
325-
--- a/numpy/core/src/umath/extobj.c 2022-10-10 13:53:09.000000000 +0200
326-
+++ b/numpy/core/src/umath/extobj.c 2022-10-10 13:53:08.000000000 +0200
327-
@@ -283,7 +283,7 @@
332+
diff --git a/numpy/core/src/umath/extobj.c b/numpy/core/src/umath/extobj.c
333+
index 6b9a27e..8de94fb 100644
334+
--- a/numpy/core/src/umath/extobj.c
335+
+++ b/numpy/core/src/umath/extobj.c
336+
@@ -283,7 +283,7 @@ _check_ufunc_fperr(int errmask, PyObject *extobj, const char *ufunc_name) {
328337
if (!errmask) {
329338
return 0;
330339
}
@@ -333,20 +342,20 @@ diff -u -r a/numpy/core/src/umath/extobj.c b/numpy/core/src/umath/extobj.c
333342
if (!fperr) {
334343
return 0;
335344
}
336-
diff -u -r a/tools/cythonize.py b/tools/cythonize.py
337-
--- a/tools/cythonize.py 2022-10-10 13:53:09.000000000 +0200
338-
+++ b/tools/cythonize.py 2022-10-10 13:53:07.000000000 +0200
339-
@@ -48,9 +48,14 @@
345+
diff --git a/tools/cythonize.py b/tools/cythonize.py
346+
index 002b2fa..fd05e01 100755
347+
--- a/tools/cythonize.py
348+
+++ b/tools/cythonize.py
349+
@@ -48,9 +48,14 @@ def process_pyx(fromfile, tofile):
340350
if tofile.endswith('.cxx'):
341351
flags.append('--cplus')
342352

343353
- subprocess.check_call(
344354
- [sys.executable, '-m', 'cython'] + flags + ["-o", tofile, fromfile])
345-
-
346355
+ print("processing: " + (" ".join(flags + ["-o", tofile, fromfile])))
347356
+ from Cython.Compiler.CmdLine import parse_command_line
348357
+ from Cython.Compiler.Main import compile
349-
+
358+
350359
+ options, sources = parse_command_line(flags + ["-o", tofile, fromfile])
351360
+ result = compile(sources, options)
352361
+ if result.num_errors > 0:

0 commit comments

Comments
 (0)