mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
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.
This commit is contained in:
parent
fd7e08a6f3
commit
ddf2e953c2
3 changed files with 11 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue