summaryrefslogtreecommitdiffstats
path: root/Python/fileutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r--Python/fileutils.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 268ffa3..610e729 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -1790,6 +1790,7 @@ _Py_fopen_obj(PyObject *path, const char *mode)
Py_END_ALLOW_THREADS
} while (f == NULL
&& errno == EINTR && !(async_err = PyErr_CheckSignals()));
+ int saved_errno = errno;
PyMem_Free(wpath);
#else
PyObject *bytes;
@@ -1812,13 +1813,14 @@ _Py_fopen_obj(PyObject *path, const char *mode)
Py_END_ALLOW_THREADS
} while (f == NULL
&& errno == EINTR && !(async_err = PyErr_CheckSignals()));
-
+ int saved_errno = errno;
Py_DECREF(bytes);
#endif
if (async_err)
return NULL;
if (f == NULL) {
+ errno = saved_errno;
PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, path);
return NULL;
}