[Python-checkins] r45260 - in python/branches/release24-maint: Doc/lib/libos.tex Misc/NEWS Modules/posixmodule.c

georg.brandl python-checkins at python.org
Tue Apr 11 08:51:27 CEST 2006


Author: georg.brandl
Date: Tue Apr 11 08:51:25 2006
New Revision: 45260

Modified:
   python/branches/release24-maint/Doc/lib/libos.tex
   python/branches/release24-maint/Misc/NEWS
   python/branches/release24-maint/Modules/posixmodule.c
Log:
Bug #1467952: backport: make os.listdir() raise if readdir() fails



Modified: python/branches/release24-maint/Doc/lib/libos.tex
==============================================================================
--- python/branches/release24-maint/Doc/lib/libos.tex	(original)
+++ python/branches/release24-maint/Doc/lib/libos.tex	Tue Apr 11 08:51:25 2006
@@ -540,7 +540,8 @@
 This function is intended for low-level I/O.  For normal usage,
 use the built-in function \function{open()}, which returns a ``file
 object'' with \method{read()} and \method{write()} methods (and many
-more).
+more).  To wrap a file descriptor in a ``file object'', use
+\function{fdopen()}.
 \end{notice}
 \end{funcdesc}
 

Modified: python/branches/release24-maint/Misc/NEWS
==============================================================================
--- python/branches/release24-maint/Misc/NEWS	(original)
+++ python/branches/release24-maint/Misc/NEWS	Tue Apr 11 08:51:25 2006
@@ -15,6 +15,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/branches/release24-maint/Modules/posixmodule.c
==============================================================================
--- python/branches/release24-maint/Modules/posixmodule.c	(original)
+++ python/branches/release24-maint/Modules/posixmodule.c	Tue Apr 11 08:51:25 2006
@@ -1699,6 +1699,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