diff --git a/Include/pymem.h b/Include/pymem.h index 671f967c891..7f74f3701b0 100644 --- a/Include/pymem.h +++ b/Include/pymem.h @@ -30,6 +30,8 @@ extern "C" { debugging info to dynamic memory blocks. The system routines have no idea what to do with that stuff, and the Python wrappers have no idea what to do with raw blocks obtained directly by the system routines then. + + The GIL must be held when using these APIs. */ /* diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 29ef1dcc99e..a63a77a3d5a 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6296,8 +6296,8 @@ posix_fdopen(PyObject *self, PyObject *args) #else fp = fdopen(fd, mode); #endif - PyMem_FREE(mode); Py_END_ALLOW_THREADS + PyMem_FREE(mode); if (fp == NULL) return posix_error(); f = PyFile_FromFile(fp, "", orgmode, fclose);