diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 3f01980af1511877645e0f8ac498788ee2bc92c0..d1c0d012328080d08279fde4d0c6306563465716 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -2435,14 +2435,10 @@ fail: if (saved_state) { PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); - res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "(O)", saved_state); + _PyErr_ChainExceptions(type, value, traceback); Py_DECREF(saved_state); - if (res == NULL) - return NULL; - Py_DECREF(res); - - PyErr_Restore(type, value, traceback); + Py_XDECREF(res); } return NULL; }