summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2014-02-10 06:05:19 (GMT)
committerLarry Hastings <larry@hastings.org>2014-02-10 06:05:19 (GMT)
commitb082731fbb413a7ff2412a447698fdd65015fd24 (patch)
tree6cb37b4aacee0af28c057079af5545cf92dd1537 /Modules
parentdc62b7e261ab88b4ab967ac2ae307eddbfa0ae09 (diff)
downloadcpython-b082731fbb413a7ff2412a447698fdd65015fd24.zip
cpython-b082731fbb413a7ff2412a447698fdd65015fd24.tar.gz
cpython-b082731fbb413a7ff2412a447698fdd65015fd24.tar.bz2
Issue #20517: Functions in the os module that accept two filenames
now register both filenames in the exception on failure. This required adding new C API functions allowing OSError exceptions to reference two filenames instead of one.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 60d0099..71abc98 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1313,6 +1313,19 @@ path_error(path_t *path)
}
+static PyObject *
+path_error2(path_t *path, path_t *path2)
+{
+#ifdef MS_WINDOWS
+ return PyErr_SetExcFromWindowsErrWithFilenameObjects(PyExc_OSError,
+ 0, path->object, path2->object);
+#else
+ return PyErr_SetFromErrnoWithFilenameObjects(PyExc_OSError,
+ path->object, path2->object);
+#endif
+}
+
+
/* POSIX generic methods */
static PyObject *
@@ -3518,7 +3531,7 @@ posix_link(PyObject *self, PyObject *args, PyObject *kwargs)
Py_END_ALLOW_THREADS
if (!result) {
- return_value = path_error(&src);
+ return_value = path_error2(&src, &dst);
goto exit;
}
#else
@@ -3536,7 +3549,7 @@ posix_link(PyObject *self, PyObject *args, PyObject *kwargs)
Py_END_ALLOW_THREADS
if (result) {
- return_value = path_error(&src);
+ return_value = path_error2(&src, &dst);
goto exit;
}
#endif
@@ -4284,7 +4297,7 @@ internal_rename(PyObject *args, PyObject *kwargs, int is_replace)
Py_END_ALLOW_THREADS
if (!result) {
- return_value = path_error(&src);
+ return_value = path_error2(&src, &dst);
goto exit;
}
@@ -4299,7 +4312,7 @@ internal_rename(PyObject *args, PyObject *kwargs, int is_replace)
Py_END_ALLOW_THREADS
if (result) {
- return_value = path_error(&src);
+ return_value = path_error2(&src, &dst);
goto exit;
}
#endif
@@ -7345,7 +7358,7 @@ posix_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
Py_END_ALLOW_THREADS
if (!result) {
- return_value = path_error(&src);
+ return_value = path_error2(&src, &dst);
goto exit;
}
@@ -7361,7 +7374,7 @@ posix_symlink(PyObject *self, PyObject *args, PyObject *kwargs)
Py_END_ALLOW_THREADS
if (result) {
- return_value = path_error(&src);
+ return_value = path_error2(&src, &dst);
goto exit;
}
#endif