bpo-37951: Lift subprocess's fork() restriction (GH-15544)

This commit is contained in:
Christian Heimes 2019-08-27 23:36:56 +02:00 committed by GitHub
parent 3224e1a6bb
commit 98d90f745d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 2 deletions

View file

@ -583,8 +583,10 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
&restore_signals, &call_setsid, &preexec_fn))
return NULL;
if (_PyInterpreterState_Get() != PyInterpreterState_Main()) {
PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");
if ((preexec_fn != Py_None) &&
(_PyInterpreterState_Get() != PyInterpreterState_Main())) {
PyErr_SetString(PyExc_RuntimeError,
"preexec_fn not supported within subinterpreters");
return NULL;
}