|
41 | 41 | #include "capi.h"
|
42 | 42 |
|
43 | 43 | #include "pycore_ceval.h" // _PyEval_SignalAsyncExc()
|
| 44 | +#include "pycore_pyerrors.h" // _PyErr_Fetch() |
| 45 | +#include "pycore_pystate.h" // _PyThreadState_GET() |
44 | 46 |
|
45 | 47 | PyObject* PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs) {
|
46 | 48 | return PyObject_Call(func, args, kwargs);
|
@@ -160,19 +162,24 @@ void Py_LeaveRecursiveCall(void)
|
160 | 162 | nb_index slot defined, and store in *pi.
|
161 | 163 | Silently reduce values larger than PY_SSIZE_T_MAX to PY_SSIZE_T_MAX,
|
162 | 164 | and silently boost values less than PY_SSIZE_T_MIN to PY_SSIZE_T_MIN.
|
163 |
| - Return 0 on error, 1 on success. */ |
164 |
| -int _PyEval_SliceIndex(PyObject *v, Py_ssize_t *pi) { |
165 |
| - if (v != Py_None) { |
| 165 | + Return 0 on error, 1 on success. |
| 166 | +*/ |
| 167 | +int |
| 168 | +_PyEval_SliceIndex(PyObject *v, Py_ssize_t *pi) |
| 169 | +{ |
| 170 | + PyThreadState *tstate = _PyThreadState_GET(); |
| 171 | + if (!Py_IsNone(v)) { |
166 | 172 | Py_ssize_t x;
|
| 173 | + // GraalPy change: don't use '_PyIndex_Check' |
167 | 174 | if (PyIndex_Check(v)) {
|
168 | 175 | x = PyNumber_AsSsize_t(v, NULL);
|
169 |
| - if (x == -1 && PyErr_Occurred()) |
| 176 | + if (x == -1 && _PyErr_Occurred(tstate)) |
170 | 177 | return 0;
|
171 | 178 | }
|
172 | 179 | else {
|
173 |
| - PyErr_SetString(PyExc_TypeError, |
174 |
| - "slice indices must be integers or " |
175 |
| - "None or have an __index__ method"); |
| 180 | + _PyErr_SetString(tstate, PyExc_TypeError, |
| 181 | + "slice indices must be integers or " |
| 182 | + "None or have an __index__ method"); |
176 | 183 | return 0;
|
177 | 184 | }
|
178 | 185 | *pi = x;
|
|
0 commit comments