Bug #1467952: os.listdir() now correctly raises an error if readdir()

fails with an error condition.
This commit is contained in:
Georg Brandl 2006-04-11 06:47:43 +00:00
parent ce27a06d37
commit bbfe4fad36
2 changed files with 9 additions and 0 deletions

View File

@ -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

View 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);