File tree Expand file tree Collapse file tree 1 file changed +3
-31
lines changed
Expand file tree Collapse file tree 1 file changed +3
-31
lines changed Original file line number Diff line number Diff line change @@ -2884,38 +2884,10 @@ PyEval_GetFuncDesc(PyObject *func)
28842884int
28852885_PyEval_SliceIndex (PyObject * v , Py_ssize_t * pi )
28862886{
2887- PyThreadState * tstate = _PyThreadState_GET ();
2888- if (!Py_IsNone (v )) {
2889- Py_ssize_t x ;
2890- if (PyLong_CheckExact (v )) {
2891- // Fast path for compact ints (single digit) -- most slice indices.
2892- if (_PyLong_IsCompact ((PyLongObject * )v )) {
2893- x = _PyLong_CompactValue ((PyLongObject * )v );
2894- }
2895- else {
2896- x = PyLong_AsSsize_t (v );
2897- if (x == -1 && _PyErr_Occurred (tstate )) {
2898- assert (_PyErr_ExceptionMatches (tstate , PyExc_OverflowError ));
2899- _PyErr_Clear (tstate );
2900- x = _PyLong_IsNegative ((PyLongObject * )v )
2901- ? PY_SSIZE_T_MIN : PY_SSIZE_T_MAX ;
2902- }
2903- }
2904- }
2905- else if (_PyIndex_Check (v )) {
2906- x = PyNumber_AsSsize_t (v , NULL );
2907- if (x == -1 && _PyErr_Occurred (tstate ))
2908- return 0 ;
2909- }
2910- else {
2911- _PyErr_SetString (tstate , PyExc_TypeError ,
2912- "slice indices must be integers or "
2913- "None or have an __index__ method" );
2914- return 0 ;
2915- }
2916- * pi = x ;
2887+ if (Py_IsNone (v )) {
2888+ return 1 ;
29172889 }
2918- return 1 ;
2890+ return _PyEval_SliceIndexNotNone ( v , pi ) ;
29192891}
29202892
29212893int
You can’t perform that action at this time.
0 commit comments