diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1121,6 +1121,9 @@ return TRUE; } +/* Note: We yielded the GIL in posix_do_stat. Must acquire before calling any + Python API functions in the following stat impls. */ + static int win32_xstat_impl_w(const wchar_t *path, struct win32_stat *result, BOOL traverse); @@ -1138,8 +1141,10 @@ if(!check_GetFinalPathNameByHandle()) { /* If the OS doesn't have GetFinalPathNameByHandle, return a NotImplementedError. */ + PyGILState_STATE state = PyGILState_Ensure(); PyErr_SetString(PyExc_NotImplementedError, "GetFinalPathNameByHandle not available on this platform"); + PyGILState_Release(state); return -1; } @@ -1236,8 +1241,10 @@ if(!check_GetFinalPathNameByHandle()) { /* If the OS doesn't have GetFinalPathNameByHandle, return a NotImplementedError. */ + PyGILState_STATE state = PyGILState_Ensure(); PyErr_SetString(PyExc_NotImplementedError, "GetFinalPathNameByHandle not available on this platform"); + PyGILState_Release(state); return -1; }