diff options
author | Ronan Pigott <ronan@rjp.ie> | 2023-09-19 23:18:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-19 23:18:23 (GMT) |
commit | ddf2e953c27d529b7e321c972ede2afce5dfb0b0 (patch) | |
tree | 4b26a45749135b495b76e754578c7c6b7b1a9297 /Modules | |
parent | fd7e08a6f35581e1189b9bf12feb51f7167a86c5 (diff) | |
download | cpython-ddf2e953c27d529b7e321c972ede2afce5dfb0b0.zip cpython-ddf2e953c27d529b7e321c972ede2afce5dfb0b0.tar.gz cpython-ddf2e953c27d529b7e321c972ede2afce5dfb0b0.tar.bz2 |
gh-109033: Return filename with os.utime errors (#109034)
The filename was previously intentionally omitted from exception because
"it might confuse the user". Uncaught exceptions are not generally a
replacement for user-facing error messages, so obscuring this
information only has the effect of making the programmer's life more
difficult.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index c434039..2c89a68 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6307,11 +6307,7 @@ os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns, _Py_time_t_to_FILE_TIME(utime.mtime_s, utime.mtime_ns, &mtime); } if (!SetFileTime(hFile, NULL, &atime, &mtime)) { - /* Avoid putting the file name into the error here, - as that may confuse the user into believing that - something is wrong with the file, when it also - could be the time stamp that gives a problem. */ - PyErr_SetFromWindowsErr(0); + path_error(path); CloseHandle(hFile); return NULL; } @@ -6351,8 +6347,7 @@ os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns, #endif if (result < 0) { - /* see previous comment about not putting filename in error here */ - posix_error(); + path_error(path); return NULL; } |