[Python-checkins] r50797 - in python/trunk: Misc/NEWS Modules/posixmodule.c
martin.v.loewis
python-checkins at python.org
Mon Jul 24 14:54:18 CEST 2006
Author: martin.v.loewis
Date: Mon Jul 24 14:54:17 2006
New Revision: 50797
Modified:
python/trunk/Misc/NEWS
python/trunk/Modules/posixmodule.c
Log:
Bug #1524310: Properly report errors from FindNextFile in os.listdir.
Will backport to 2.4.
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Mon Jul 24 14:54:17 2006
@@ -12,6 +12,8 @@
Core and builtins
-----------------
+- Bug #1524310: Properly report errors from FindNextFile in os.listdir.
+
- Patch #1232023: Stop including current directory in search
path on Windows.
Modified: python/trunk/Modules/posixmodule.c
==============================================================================
--- python/trunk/Modules/posixmodule.c (original)
+++ python/trunk/Modules/posixmodule.c Mon Jul 24 14:54:17 2006
@@ -1862,6 +1862,15 @@
Py_BEGIN_ALLOW_THREADS
result = FindNextFileW(hFindFile, &wFileData);
Py_END_ALLOW_THREADS
+ /* FindNextFile sets error to ERROR_NO_MORE_FILES if
+ it got to the end of the directory. */
+ if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
+ Py_DECREF(d);
+ win32_error_unicode("FindNextFileW", wnamebuf);
+ FindClose(hFindFile);
+ free(wnamebuf);
+ return NULL;
+ }
} while (result == TRUE);
if (FindClose(hFindFile) == FALSE) {
@@ -1921,6 +1930,14 @@
Py_BEGIN_ALLOW_THREADS
result = FindNextFile(hFindFile, &FileData);
Py_END_ALLOW_THREADS
+ /* FindNextFile sets error to ERROR_NO_MORE_FILES if
+ it got to the end of the directory. */
+ if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
+ Py_DECREF(d);
+ win32_error("FindNextFile", namebuf);
+ FindClose(hFindFile);
+ return NULL;
+ }
} while (result == TRUE);
if (FindClose(hFindFile) == FALSE) {
More information about the Python-checkins
mailing list