File tree Expand file tree Collapse file tree 2 files changed +620
-28
lines changed
graalpython/com.oracle.graal.python.cext/src Expand file tree Collapse file tree 2 files changed +620
-28
lines changed Original file line number Diff line number Diff line change @@ -155,3 +155,27 @@ void Py_LeaveRecursiveCall(void)
155
155
{
156
156
_Py_LeaveRecursiveCall ();
157
157
}
158
+
159
+ /* Extract a slice index from a PyLong or an object with the
160
+ nb_index slot defined, and store in *pi.
161
+ Silently reduce values larger than PY_SSIZE_T_MAX to PY_SSIZE_T_MAX,
162
+ 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 ) {
166
+ Py_ssize_t x ;
167
+ if (PyIndex_Check (v )) {
168
+ x = PyNumber_AsSsize_t (v , NULL );
169
+ if (x == -1 && PyErr_Occurred ())
170
+ return 0 ;
171
+ }
172
+ else {
173
+ PyErr_SetString (PyExc_TypeError ,
174
+ "slice indices must be integers or "
175
+ "None or have an __index__ method" );
176
+ return 0 ;
177
+ }
178
+ * pi = x ;
179
+ }
180
+ return 1 ;
181
+ }
You can’t perform that action at this time.
0 commit comments