summaryrefslogtreecommitdiffstats
path: root/Modules/_io/_iomodule.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-02-24 21:43:03 (GMT)
committerGitHub <noreply@github.com>2023-02-24 21:43:03 (GMT)
commit2db23d10bf64bf7c061fd95c6a8079ddc5c9aa4b (patch)
treeaa29d63d7151d976ea301f5fadff1821333690c9 /Modules/_io/_iomodule.c
parent568fc0dee42a353f327b059a48f97c911de904b3 (diff)
downloadcpython-2db23d10bf64bf7c061fd95c6a8079ddc5c9aa4b.zip
cpython-2db23d10bf64bf7c061fd95c6a8079ddc5c9aa4b.tar.gz
cpython-2db23d10bf64bf7c061fd95c6a8079ddc5c9aa4b.tar.bz2
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Modules/) (#102196)
Diffstat (limited to 'Modules/_io/_iomodule.c')
-rw-r--r--Modules/_io/_iomodule.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index 55b6535..d8d836b 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -437,10 +437,9 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
error:
if (result != NULL) {
- PyObject *exc, *val, *tb, *close_result;
- PyErr_Fetch(&exc, &val, &tb);
- close_result = PyObject_CallMethodNoArgs(result, &_Py_ID(close));
- _PyErr_ChainExceptions(exc, val, tb);
+ PyObject *exc = PyErr_GetRaisedException();
+ PyObject *close_result = PyObject_CallMethodNoArgs(result, &_Py_ID(close));
+ _PyErr_ChainExceptions1(exc);
Py_XDECREF(close_result);
Py_DECREF(result);
}