File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,8 +141,11 @@ PyObject_GetItem(PyObject *o, PyObject *key)
141141 return null_error ();
142142
143143 m = o -> ob_type -> tp_as_mapping ;
144- if (m && m -> mp_subscript )
145- return m -> mp_subscript (o , key );
144+ if (m && m -> mp_subscript ) {
145+ PyObject * item = m -> mp_subscript (o , key );
146+ assert ((item != NULL ) ^ (PyErr_Occurred () != NULL ));
147+ return item ;
148+ }
146149
147150 if (o -> ob_type -> tp_as_sequence ) {
148151 if (PyIndex_Check (key )) {
@@ -1526,8 +1529,10 @@ PySequence_GetItem(PyObject *s, Py_ssize_t i)
15261529 if (i < 0 ) {
15271530 if (m -> sq_length ) {
15281531 Py_ssize_t l = (* m -> sq_length )(s );
1529- if (l < 0 )
1532+ if (l < 0 ) {
1533+ assert (PyErr_Occurred ());
15301534 return NULL ;
1535+ }
15311536 i += l ;
15321537 }
15331538 }
Original file line number Diff line number Diff line change @@ -2307,7 +2307,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
23072307 }
23082308 else {
23092309 v = PyObject_GetItem (locals , name );
2310- if (v == NULL && _PyErr_OCCURRED () ) {
2310+ if (v == NULL ) {
23112311 if (!PyErr_ExceptionMatches (PyExc_KeyError ))
23122312 goto error ;
23132313 PyErr_Clear ();
@@ -2426,7 +2426,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
24262426 }
24272427 else {
24282428 value = PyObject_GetItem (locals , name );
2429- if (value == NULL && PyErr_Occurred () ) {
2429+ if (value == NULL ) {
24302430 if (!PyErr_ExceptionMatches (PyExc_KeyError ))
24312431 goto error ;
24322432 PyErr_Clear ();
You can’t perform that action at this time.
0 commit comments