bpo-37951: Lift subprocess's fork() restriction (GH-15544)
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 60c8eab..f68d362 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -583,8 +583,10 @@
&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;
}