Skip to content

Commit 05b2833

Browse files
committed
Modules/_io/textio.c
1 parent 6157ce8 commit 05b2833

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Modules/_io/textio.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,11 +2827,10 @@ _io_TextIOWrapper_tell_impl(textio *self)
28272827

28282828
fail:
28292829
if (saved_state) {
2830-
PyObject *type, *value, *traceback;
2831-
PyErr_Fetch(&type, &value, &traceback);
2830+
PyObject *exc = PyErr_GetRaisedException();
28322831
res = PyObject_CallMethodOneArg(
28332832
self->decoder, &_Py_ID(setstate), saved_state);
2834-
_PyErr_ChainExceptions(type, value, traceback);
2833+
_PyErr_ChainExceptions1(exc);
28352834
Py_DECREF(saved_state);
28362835
Py_XDECREF(res);
28372836
}
@@ -3028,24 +3027,28 @@ _io_TextIOWrapper_close_impl(textio *self)
30283027
Py_RETURN_NONE; /* stream already closed */
30293028
}
30303029
else {
3031-
PyObject *exc = NULL, *val, *tb;
3030+
PyObject *exc = NULL;
30323031
if (self->finalizing) {
30333032
res = PyObject_CallMethodOneArg(self->buffer, &_Py_ID(_dealloc_warn),
30343033
(PyObject *)self);
3035-
if (res)
3034+
if (res) {
30363035
Py_DECREF(res);
3037-
else
3036+
}
3037+
else {
30383038
PyErr_Clear();
3039+
}
30393040
}
30403041
res = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(flush));
3041-
if (res == NULL)
3042-
PyErr_Fetch(&exc, &val, &tb);
3043-
else
3042+
if (res == NULL) {
3043+
exc = PyErr_GetRaisedException();
3044+
}
3045+
else {
30443046
Py_DECREF(res);
3047+
}
30453048

30463049
res = PyObject_CallMethodNoArgs(self->buffer, &_Py_ID(close));
30473050
if (exc != NULL) {
3048-
_PyErr_ChainExceptions(exc, val, tb);
3051+
_PyErr_ChainExceptions1(exc);
30493052
Py_CLEAR(res);
30503053
}
30513054
return res;

0 commit comments

Comments
 (0)