--- Python-2.5.1/Modules/posixmodule.c.orig 2007-04-04 14:30:56.000000000 -0400 +++ Python-2.5.1/Modules/posixmodule.c 2008-06-14 17:35:47.000000000 -0400 @@ -2160,7 +2160,6 @@ struct dirent *ep; int arg_is_unicode = 1; - errno = 0; if (!PyArg_ParseTuple(args, "U:listdir", &v)) { arg_is_unicode = 0; PyErr_Clear(); @@ -2176,6 +2175,7 @@ return NULL; } for (;;) { + errno = 0; Py_BEGIN_ALLOW_THREADS ep = readdir(dirp); Py_END_ALLOW_THREADS