summaryrefslogtreecommitdiffstats
path: root/Modules/_io/_iomodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_io/_iomodule.c')
-rw-r--r--Modules/_io/_iomodule.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index 29db164..04c4445 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -529,14 +529,8 @@ io_open(PyObject *self, PyObject *args, PyObject *kwds)
PyObject *exc, *val, *tb, *close_result;
PyErr_Fetch(&exc, &val, &tb);
close_result = PyObject_CallMethod(result, "close", NULL);
- if (close_result != NULL) {
- Py_DECREF(close_result);
- PyErr_Restore(exc, val, tb);
- } else {
- Py_XDECREF(exc);
- Py_XDECREF(val);
- Py_XDECREF(tb);
- }
+ _PyErr_ReplaceException(exc, val, tb);
+ Py_XDECREF(close_result);
Py_DECREF(result);
}
Py_XDECREF(modeobj);