Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b73caab

Browse files
committed
Issue #6915: Under Windows, os.listdir() didn't release the Global
Interpreter Lock around all system calls. Original patch by Ryan Kelly.
1 parent 5af4f4b commit b73caab

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ Jacob Kaplan-Moss
419419
Lou Kates
420420
Hiroaki Kawai
421421
Sebastien Keim
422+
Ryan Kelly
422423
Robert Kern
423424
Randall Kern
424425
Magnus Kessler

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Core and Builtins
3030
Extensions
3131
----------
3232

33+
- Issue #6915: Under Windows, os.listdir() didn't release the Global
34+
Interpreter Lock around all system calls. Original patch by Ryan Kelly.
35+
3336
- Issue #8524: Add a detach() method to socket objects, so as to put the
3437
socket into the closed state without closing the underlying file
3538
descriptor.

Modules/posixmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ win32_stat_w(const wchar_t* path, struct win32_stat *result)
12291229
/* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */
12301230
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS,
12311231
NULL);
1232-
1232+
12331233
if(hFile == INVALID_HANDLE_VALUE) {
12341234
/* Either the target doesn't exist, or we don't have access to
12351235
get a handle to it. If the former, we need to return an error.
@@ -2353,7 +2353,9 @@ posix_listdir(PyObject *self, PyObject *args)
23532353
free(wnamebuf);
23542354
return NULL;
23552355
}
2356+
Py_BEGIN_ALLOW_THREADS
23562357
hFindFile = FindFirstFileW(wnamebuf, &wFileData);
2358+
Py_END_ALLOW_THREADS
23572359
if (hFindFile == INVALID_HANDLE_VALUE) {
23582360
int error = GetLastError();
23592361
if (error == ERROR_FILE_NOT_FOUND) {
@@ -2430,7 +2432,9 @@ posix_listdir(PyObject *self, PyObject *args)
24302432
if ((d = PyList_New(0)) == NULL)
24312433
return NULL;
24322434

2435+
Py_BEGIN_ALLOW_THREADS
24332436
hFindFile = FindFirstFile(namebuf, &FileData);
2437+
Py_END_ALLOW_THREADS
24342438
if (hFindFile == INVALID_HANDLE_VALUE) {
24352439
int error = GetLastError();
24362440
if (error == ERROR_FILE_NOT_FOUND)

0 commit comments

Comments
 (0)