diff -r 62235755609f Modules/socketmodule.c --- a/Modules/socketmodule.c Mon Aug 03 10:39:09 2015 +1200 +++ b/Modules/socketmodule.c Mon Aug 03 10:55:26 2015 +0200 @@ -719,8 +719,10 @@ int deadline_initialized = 0; int res; +#ifdef WITH_THREAD /* sock_call() must be called with the GIL held. */ assert(PyGILState_Check()); +#endif /* outer loop to retry select() when select() is interrupted by a signal or to retry select()+sock_func() on false positive (see above) */ diff -r 62235755609f Python/fileutils.c --- a/Python/fileutils.c Mon Aug 03 10:39:09 2015 +1200 +++ b/Python/fileutils.c Mon Aug 03 10:55:26 2015 +0200 @@ -987,7 +987,9 @@ _Py_open(const char *pathname, int flags) { /* _Py_open() must be called with the GIL held. */ +#ifdef WITH_THREAD assert(PyGILState_Check()); +#endif + return _Py_open_impl(pathname, flags, 1); } @@ -1080,7 +1082,9 @@ wchar_t wmode[10]; int usize; +#ifdef WITH_THREAD assert(PyGILState_Check()); +#endif if (!PyUnicode_Check(path)) { PyErr_Format(PyExc_TypeError, @@ -1108,7 +1112,9 @@ PyObject *bytes; char *path_bytes; +#ifdef WITH_THREAD assert(PyGILState_Check()); +#endif if (!PyUnicode_FSConverter(path, &bytes)) return NULL;