]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Bug #1524310: Properly report errors from FindNextFile in os.listdir.
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 24 Jul 2006 12:57:47 +0000 (12:57 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 24 Jul 2006 12:57:47 +0000 (12:57 +0000)
Misc/NEWS
Modules/posixmodule.c

index 715a7a92c12c4f73a32c3573dc8c55e8a31a2842..e18a3c8a34cc5211b69847b1975cbc6c1be7bbf2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.4.4c1?
 Core and builtins
 -----------------
 
+- Bug #1524310: Properly report errors from FindNextFile in os.listdir.
+
 - Bug #927248: Recursive method-wrapper objects can now safely
   be released.
 
index 1e6640e42cd708596be8338a1949506b795e09ec..8d0363e7ddf2bf598062c26b86eee1a1eca6c761 100644 (file)
@@ -1512,6 +1512,13 @@ posix_listdir(PyObject *self, PyObject *args)
                                Py_DECREF(v);
                        } while (FindNextFileW(hFindFile, &wFileData) == TRUE);
 
+                       if (d && GetLastError() != ERROR_NO_MORE_FILES) {
+                               Py_DECREF(d);
+                               win32_error_unicode("FindNextFileW", wnamebuf);
+                               FindClose(hFindFile);
+                               return NULL;
+                       }
+
                        if (FindClose(hFindFile) == FALSE) {
                                Py_DECREF(d);
                                return win32_error_unicode("FindClose", wnamebuf);
@@ -1566,6 +1573,13 @@ posix_listdir(PyObject *self, PyObject *args)
                Py_DECREF(v);
        } while (FindNextFile(hFindFile, &FileData) == TRUE);
 
+       if (d && GetLastError() != ERROR_NO_MORE_FILES) {
+               Py_DECREF(d);
+               win32_error("FindNextFileW", namebuf);
+               FindClose(hFindFile);
+               return NULL;
+       }
+
        if (FindClose(hFindFile) == FALSE) {
                Py_DECREF(d);
                return win32_error("FindClose", namebuf);