]> granicus.if.org Git - python/commitdiff
Bug #1467952: os.listdir() now correctly raises an error if readdir()
authorGeorg Brandl <georg@python.org>
Tue, 11 Apr 2006 06:47:43 +0000 (06:47 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 11 Apr 2006 06:47:43 +0000 (06:47 +0000)
fails with an error condition.

Misc/NEWS
Modules/posixmodule.c

index 7418daa1739b8a3d486c4d2c5fb55ac8aff7485d..4dacebd081b89ee26cd20527941e1969d5c488af 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -41,6 +41,9 @@ Core and builtins
 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
index bc966817a76b58c3e9fbc002c9a499d1aaf683d3..39765b2b91e7e2469f01366802b396b7529f0bf4 100644 (file)
@@ -1901,6 +1901,12 @@ posix_listdir(PyObject *self, PyObject *args)
                }
                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);