summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-10-11 07:54:42 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-10-11 07:54:42 (GMT)
commitbc5b80bac1d3db5779fcace4922bfc7eb8b964fa (patch)
treef2683edb7faa3a850b6a387bdc52166af5525e55 /Modules
parentb16e12aaaa3d6b3f47dc1400e900c2d4aae0f337 (diff)
downloadcpython-bc5b80bac1d3db5779fcace4922bfc7eb8b964fa.zip
cpython-bc5b80bac1d3db5779fcace4922bfc7eb8b964fa.tar.gz
cpython-bc5b80bac1d3db5779fcace4922bfc7eb8b964fa.tar.bz2
Close #24784: Fix compilation without thread support
Add "#ifdef WITH_THREAD" around cals to: * PyGILState_Check() * _PyImport_AcquireLock() * _PyImport_ReleaseLock()
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_posixsubprocess.c12
-rw-r--r--Modules/socketmodule.c2
2 files changed, 12 insertions, 2 deletions
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index a327fc5..800b301 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -549,7 +549,9 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
int need_to_reenable_gc = 0;
char *const *exec_array, *const *argv = NULL, *const *envp = NULL;
Py_ssize_t arg_num;
+#ifdef WITH_THREAD
int import_lock_held = 0;
+#endif
if (!PyArg_ParseTuple(
args, "OOpOOOiiiiiiiiiiO:fork_exec",
@@ -644,8 +646,10 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
preexec_fn_args_tuple = PyTuple_New(0);
if (!preexec_fn_args_tuple)
goto cleanup;
+#ifdef WITH_THREAD
_PyImport_AcquireLock();
import_lock_held = 1;
+#endif
}
if (cwd_obj != Py_None) {
@@ -688,12 +692,14 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
/* Capture the errno exception before errno can be clobbered. */
PyErr_SetFromErrno(PyExc_OSError);
}
- if (preexec_fn != Py_None &&
- _PyImport_ReleaseLock() < 0 && !PyErr_Occurred()) {
+#ifdef WITH_THREAD
+ if (preexec_fn != Py_None
+ && _PyImport_ReleaseLock() < 0 && !PyErr_Occurred()) {
PyErr_SetString(PyExc_RuntimeError,
"not holding the import lock");
}
import_lock_held = 0;
+#endif
/* Parent process */
if (envp)
@@ -716,8 +722,10 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
return PyLong_FromPid(pid);
cleanup:
+#ifdef WITH_THREAD
if (import_lock_held)
_PyImport_ReleaseLock();
+#endif
if (envp)
_Py_FreeCharPArray(envp);
if (argv)
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index d9c70f8..bae9634 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -719,8 +719,10 @@ sock_call_ex(PySocketSockObject *s,
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) */