Merged revisions 84489 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84489 | antoine.pitrou | 2010-09-04 19:21:57 +0200 (sam., 04 sept. 2010) | 4 lines

  Issue #7736: Release the GIL around calls to opendir() and closedir()
  in the posix module.  Patch by Marcin Bachry.
........
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 5a5badd..ed2447b 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2493,11 +2493,16 @@
     if (!PyArg_ParseTuple(args, "O&:listdir", PyUnicode_FSConverter, &oname))
         return NULL;
     name = bytes2str(oname, 1);
-    if ((dirp = opendir(name)) == NULL) {
+    Py_BEGIN_ALLOW_THREADS
+    dirp = opendir(name);
+    Py_END_ALLOW_THREADS
+    if (dirp == NULL) {
         return posix_error_with_allocated_filename(oname);
     }
     if ((d = PyList_New(0)) == NULL) {
+        Py_BEGIN_ALLOW_THREADS
         closedir(dirp);
+        Py_END_ALLOW_THREADS
         release_bytes(oname);
         return NULL;
     }
@@ -2510,7 +2515,9 @@
             if (errno == 0) {
                 break;
             } else {
+                Py_BEGIN_ALLOW_THREADS
                 closedir(dirp);
+                Py_END_ALLOW_THREADS
                 Py_DECREF(d);
                 return posix_error_with_allocated_filename(oname);
             }
@@ -2550,7 +2557,9 @@
         }
         Py_DECREF(v);
     }
+    Py_BEGIN_ALLOW_THREADS
     closedir(dirp);
+    Py_END_ALLOW_THREADS
     release_bytes(oname);
 
     return d;