mirror of
https://github.com/python/cpython.git
synced 2025-11-10 14:31:24 +00:00
Fix for bug #110670 - Win32 os.listdir raises confusing errors:
The existing win32_error() function now returns the new(ish) WindowsError, ensuring we get correct error messages.
This commit is contained in:
parent
557a044f74
commit
33a6da9971
1 changed files with 7 additions and 3 deletions
|
|
@ -349,12 +349,16 @@ posix_error_with_filename(char* name)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
win32_error(char* function, char* filename)
|
win32_error(char* function, char* filename)
|
||||||
{
|
{
|
||||||
/* XXX this could be improved */
|
/* XXX We should pass the function name along in the future.
|
||||||
|
(_winreg.c also wants to pass the function name.)
|
||||||
|
This would however require an additional param to the
|
||||||
|
Windows error object, which is non-trivial.
|
||||||
|
*/
|
||||||
errno = GetLastError();
|
errno = GetLastError();
|
||||||
if (filename)
|
if (filename)
|
||||||
return PyErr_SetFromErrnoWithFilename(PyExc_OSError, filename);
|
return PyErr_SetFromWindowsErrWithFilename(errno, filename);
|
||||||
else
|
else
|
||||||
return PyErr_SetFromErrno(PyExc_OSError);
|
return PyErr_SetFromWindowsErr(errno);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue