[Python-checkins] r50798 - in python/branches/release24-maint: Misc/NEWS Modules/posixmodule.c

martin.v.loewis python-checkins at python.org
Mon Jul 24 14:57:50 CEST 2006


Author: martin.v.loewis
Date: Mon Jul 24 14:57:47 2006
New Revision: 50798

Modified:
   python/branches/release24-maint/Misc/NEWS
   python/branches/release24-maint/Modules/posixmodule.c
Log:
Bug #1524310: Properly report errors from FindNextFile in os.listdir.


Modified: python/branches/release24-maint/Misc/NEWS
==============================================================================
--- python/branches/release24-maint/Misc/NEWS	(original)
+++ python/branches/release24-maint/Misc/NEWS	Mon Jul 24 14:57:47 2006
@@ -12,6 +12,8 @@
 Core and builtins
 -----------------
 
+- Bug #1524310: Properly report errors from FindNextFile in os.listdir.
+
 - Bug #927248: Recursive method-wrapper objects can now safely
   be released.
 

Modified: python/branches/release24-maint/Modules/posixmodule.c
==============================================================================
--- python/branches/release24-maint/Modules/posixmodule.c	(original)
+++ python/branches/release24-maint/Modules/posixmodule.c	Mon Jul 24 14:57:47 2006
@@ -1512,6 +1512,13 @@
 				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 @@
 		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);


More information about the Python-checkins mailing list