Skip to content

Commit 0ba7a7f

Browse files
committed
Work around missing AttributeError kwargs
1 parent 16c3e88 commit 0ba7a7f

File tree

2 files changed

+189
-1
lines changed

2 files changed

+189
-1
lines changed

graalpython/lib-graalpython/patches/metadata.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,13 @@ patch = 'numba-0.59.1.patch'
296296
license = 'BSD-2-Clause'
297297

298298
[[numpy.rules]]
299-
version = '>= 2.0.0rc1, < 2.3'
299+
version = '== 2.2.4'
300+
patch = 'numpy-2.2.4.patch'
301+
license = 'BSD-3-Clause'
302+
dist-type = 'sdist'
303+
304+
[[numpy.rules]]
305+
version = '>= 2.0.0rc1, < 2.1'
300306
patch = 'numpy-2.0.0.patch'
301307
license = 'BSD-3-Clause'
302308
dist-type = 'sdist'
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
diff --git a/numpy/__init__.py b/numpy/__init__.py
2+
index 2a4fd03..4df4f2d 100644
3+
--- a/numpy/__init__.py
4+
+++ b/numpy/__init__.py
5+
@@ -371,7 +371,7 @@ def __getattr__(attr):
6+
return char
7+
elif attr == "array_api":
8+
raise AttributeError("`numpy.array_api` is not available from "
9+
- "numpy 2.0 onwards", name=None)
10+
+ "numpy 2.0 onwards")
11+
elif attr == "core":
12+
import numpy.core as core
13+
return core
14+
@@ -384,7 +384,7 @@ def __getattr__(attr):
15+
return distutils
16+
else:
17+
raise AttributeError("`numpy.distutils` is not available from "
18+
- "Python 3.12 onwards", name=None)
19+
+ "Python 3.12 onwards")
20+
21+
if attr in __future_scalars__:
22+
# And future warnings for those that will change, but also give
23+
@@ -394,13 +394,12 @@ def __getattr__(attr):
24+
"corresponding NumPy scalar.", FutureWarning, stacklevel=2)
25+
26+
if attr in __former_attrs__:
27+
- raise AttributeError(__former_attrs__[attr], name=None)
28+
+ raise AttributeError(__former_attrs__[attr])
29+
30+
if attr in __expired_attributes__:
31+
raise AttributeError(
32+
f"`np.{attr}` was removed in the NumPy 2.0 release. "
33+
f"{__expired_attributes__[attr]}",
34+
- name=None
35+
)
36+
37+
if attr == "chararray":
38+
diff --git a/numpy/_core/include/numpy/ndarrayobject.h b/numpy/_core/include/numpy/ndarrayobject.h
39+
index 0462625..3625e34 100644
40+
--- a/numpy/_core/include/numpy/ndarrayobject.h
41+
+++ b/numpy/_core/include/numpy/ndarrayobject.h
42+
@@ -220,7 +220,7 @@ NPY_TITLE_KEY_check(PyObject *key, PyObject *value)
43+
if (key == title) {
44+
return 1;
45+
}
46+
-#ifdef PYPY_VERSION
47+
+#if defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)
48+
/*
49+
* On PyPy, dictionary keys do not always preserve object identity.
50+
* Fall back to comparison by value.
51+
diff --git a/numpy/_core/src/multiarray/compiled_base.c b/numpy/_core/src/multiarray/compiled_base.c
52+
index e3af951..48a7030 100644
53+
--- a/numpy/_core/src/multiarray/compiled_base.c
54+
+++ b/numpy/_core/src/multiarray/compiled_base.c
55+
@@ -1465,6 +1465,7 @@ fail:
56+
NPY_NO_EXPORT PyObject *
57+
arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *const *args, Py_ssize_t len_args)
58+
{
59+
+#if 0 // GraalPy change
60+
PyObject *obj;
61+
PyObject *str;
62+
const char *docstr;
63+
@@ -1569,6 +1570,7 @@ arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *const *args, Py_ssize_t
64+
}
65+
66+
#undef _ADDDOC
67+
+#endif // GraalPy change
68+
69+
Py_RETURN_NONE;
70+
}
71+
diff --git a/numpy/_core/src/multiarray/shape.c b/numpy/_core/src/multiarray/shape.c
72+
index 340fe72..8f13674 100644
73+
--- a/numpy/_core/src/multiarray/shape.c
74+
+++ b/numpy/_core/src/multiarray/shape.c
75+
@@ -97,6 +97,11 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,
76+
"cannot resize an array with refcheck=True on PyPy.\n"
77+
"Use the np.resize function or refcheck=False");
78+
return NULL;
79+
+#elif defined(GRAALVM_PYTHON)
80+
+ PyErr_SetString(PyExc_ValueError,
81+
+ "cannot resize an array with refcheck=True on GraalPy.\n"
82+
+ "Use the np.resize function or refcheck=False");
83+
+ return NULL;
84+
#else
85+
refcnt = Py_REFCNT(self);
86+
#endif /* PYPY_VERSION */
87+
diff --git a/numpy/_core/src/multiarray/stringdtype/dtype.c b/numpy/_core/src/multiarray/stringdtype/dtype.c
88+
index 0350375..8b254cb 100644
89+
--- a/numpy/_core/src/multiarray/stringdtype/dtype.c
90+
+++ b/numpy/_core/src/multiarray/stringdtype/dtype.c
91+
@@ -841,7 +841,7 @@ init_string_dtype(void)
92+
};
93+
94+
/* Loaded dynamically, so needs to be set here: */
95+
- Py_TYPE(((PyObject *)&PyArray_StringDType)) = &PyArrayDTypeMeta_Type;
96+
+ Py_SET_TYPE(((PyObject *)&PyArray_StringDType), &PyArrayDTypeMeta_Type);
97+
((PyTypeObject *)&PyArray_StringDType)->tp_base = &PyArrayDescr_Type;
98+
if (PyType_Ready((PyTypeObject *)&PyArray_StringDType) < 0) {
99+
return -1;
100+
diff --git a/numpy/_core/src/multiarray/temp_elide.c b/numpy/_core/src/multiarray/temp_elide.c
101+
index 662a2fa..791ede8 100644
102+
--- a/numpy/_core/src/multiarray/temp_elide.c
103+
+++ b/numpy/_core/src/multiarray/temp_elide.c
104+
@@ -58,7 +58,7 @@
105+
* supported too by using the appropriate Windows APIs.
106+
*/
107+
108+
-#if defined HAVE_BACKTRACE && defined HAVE_DLFCN_H && ! defined PYPY_VERSION
109+
+#if defined HAVE_BACKTRACE && defined HAVE_DLFCN_H && ! defined PYPY_VERSION && !defined(GRAALVM_PYTHON)
110+
111+
#include <feature_detection_misc.h>
112+
113+
diff --git a/numpy/_core/src/npymath/ieee754.c.src b/numpy/_core/src/npymath/ieee754.c.src
114+
index 8fccc9a..3bb9cf0 100644
115+
--- a/numpy/_core/src/npymath/ieee754.c.src
116+
+++ b/numpy/_core/src/npymath/ieee754.c.src
117+
@@ -362,6 +362,11 @@ int npy_get_floatstatus_barrier(char* param)
118+
* By using a volatile, the compiler cannot reorder this call
119+
*/
120+
if (param != NULL) {
121+
+ // GraalPy change: the pointer needs to be dereferenced to establish
122+
+ // a data dependency to to ensure the compiler won't reorder the call
123+
+ if (points_to_py_handle_space(param)) {
124+
+ param = (char*)pointer_to_stub(param);
125+
+ }
126+
volatile char NPY_UNUSED(c) = *(char*)param;
127+
}
128+
129+
diff --git a/numpy/_core/src/npymath/ieee754.cpp b/numpy/_core/src/npymath/ieee754.cpp
130+
index 1c59bf3..519fabc 100644
131+
--- a/numpy/_core/src/npymath/ieee754.cpp
132+
+++ b/numpy/_core/src/npymath/ieee754.cpp
133+
@@ -428,6 +428,11 @@ npy_get_floatstatus_barrier(char *param)
134+
* By using a volatile, the compiler cannot reorder this call
135+
*/
136+
if (param != NULL) {
137+
+ // GraalPy change: the pointer needs to be dereferenced to establish
138+
+ // a data dependency to to ensure the compiler won't reorder the call
139+
+ if (points_to_py_handle_space(param)) {
140+
+ param = (char*)pointer_to_stub(param);
141+
+ }
142+
volatile char NPY_UNUSED(c) = *(char *)param;
143+
}
144+
145+
diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py
146+
index 928121c..bbe6a7e 100644
147+
--- a/numpy/lib/__init__.py
148+
+++ b/numpy/lib/__init__.py
149+
@@ -70,7 +70,6 @@ def __getattr__(attr):
150+
"numpy.lib.emath was an alias for emath module that was removed "
151+
"in NumPy 2.0. Replace usages of numpy.lib.emath with "
152+
"numpy.emath.",
153+
- name=None
154+
)
155+
elif attr in (
156+
"histograms", "type_check", "nanfunctions", "function_base",
157+
@@ -81,13 +80,11 @@ def __getattr__(attr):
158+
f"numpy.lib.{attr} is now private. If you are using a public "
159+
"function, it should be available in the main numpy namespace, "
160+
"otherwise check the NumPy 2.0 migration guide.",
161+
- name=None
162+
)
163+
elif attr == "arrayterator":
164+
raise AttributeError(
165+
"numpy.lib.arrayterator submodule is now private. To access "
166+
"Arrayterator class use numpy.lib.Arrayterator.",
167+
- name=None
168+
)
169+
else:
170+
raise AttributeError("module {!r} has no attribute "
171+
diff --git a/vendored-meson/meson/mesonbuild/utils/universal.py b/vendored-meson/meson/mesonbuild/utils/universal.py
172+
index 6aee268..539be8b 100644
173+
--- a/vendored-meson/meson/mesonbuild/utils/universal.py
174+
+++ b/vendored-meson/meson/mesonbuild/utils/universal.py
175+
@@ -728,6 +728,7 @@ def windows_detect_native_arch() -> str:
176+
"""
177+
if sys.platform != 'win32':
178+
return ''
179+
+ return 'amd64' # Workaround for GraalPy bug on Windows with kernel32.GetCurrentProcess()
180+
try:
181+
import ctypes
182+
process_arch = ctypes.c_ushort()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy