]> granicus.if.org Git - python/commitdiff
Fix for bug #110670 - Win32 os.listdir raises confusing errors:
authorMark Hammond <mhammond@skippinet.com.au>
Tue, 15 Aug 2000 00:46:38 +0000 (00:46 +0000)
committerMark Hammond <mhammond@skippinet.com.au>
Tue, 15 Aug 2000 00:46:38 +0000 (00:46 +0000)
The existing win32_error() function now returns the new(ish) WindowsError, ensuring we get correct error messages.

Modules/posixmodule.c

index e7f35cfdbd2fe2baf4ba206d08a0032a94d2369d..d7755bf95ee802600196c69b4ce128c037a568c9 100644 (file)
@@ -349,12 +349,16 @@ posix_error_with_filename(char* name)
 static PyObject *
 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();
        if (filename)
-               return PyErr_SetFromErrnoWithFilename(PyExc_OSError, filename);
+               return PyErr_SetFromWindowsErrWithFilename(errno, filename);
        else
-               return PyErr_SetFromErrno(PyExc_OSError);
+               return PyErr_SetFromWindowsErr(errno);
 }
 #endif