[Python-checkins] r45259 - in python/trunk: Misc/NEWS Modules/posixmodule.c

georg.brandl python-checkins at python.org
Tue Apr 11 08:47:45 CEST 2006


Author: georg.brandl
Date: Tue Apr 11 08:47:43 2006
New Revision: 45259

Modified:
   python/trunk/Misc/NEWS
   python/trunk/Modules/posixmodule.c
Log:
Bug #1467952: os.listdir() now correctly raises an error if readdir()
fails with an error condition.


Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue Apr 11 08:47:43 2006
@@ -41,6 +41,9 @@
 Extension Modules
 -----------------
 
+- Bug #1467952: os.listdir() now correctly raises an error if readdir()
+  fails with an error condition.
+
 - Fix bsddb.db.DBError derived exceptions so they can be unpickled.
 
 Library

Modified: python/trunk/Modules/posixmodule.c
==============================================================================
--- python/trunk/Modules/posixmodule.c	(original)
+++ python/trunk/Modules/posixmodule.c	Tue Apr 11 08:47:43 2006
@@ -1901,6 +1901,12 @@
 		}
 		Py_DECREF(v);
 	}
+	if (errno != 0 && d != NULL) {
+		/* readdir() returned NULL and set errno */
+		closedir(dirp);
+		Py_DECREF(d);
+		return posix_error_with_allocated_filename(name); 
+	}
 	closedir(dirp);
 	PyMem_Free(name);
 


More information about the Python-checkins mailing list