Skip to content

Commit e13a305

Browse files
Add _PyInterpreterConfig_INIT.
1 parent 83ea491 commit e13a305

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Include/cpython/initconfig.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,14 @@ typedef struct {
250250
int allow_daemon_threads;
251251
} _PyInterpreterConfig;
252252

253+
#define _PyInterpreterConfig_INIT \
254+
{ \
255+
.allow_fork = 0, \
256+
.allow_exec = 0, \
257+
.allow_threads = 1, \
258+
.allow_daemon_threads = 0, \
259+
}
260+
253261
#define _PyInterpreterConfig_LEGACY_INIT \
254262
{ \
255263
.allow_fork = 1, \

Modules/_xxsubinterpretersmodule.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,12 +2003,9 @@ interp_create(PyObject *self, PyObject *args, PyObject *kwds)
20032003

20042004
// Create and initialize the new interpreter.
20052005
PyThreadState *save_tstate = _PyThreadState_GET();
2006-
const _PyInterpreterConfig config = {
2007-
.allow_fork = !isolated,
2008-
.allow_exec = !isolated,
2009-
.allow_threads = 1,
2010-
.allow_daemon_threads = !isolated,
2011-
};
2006+
const _PyInterpreterConfig config = isolated
2007+
? (_PyInterpreterConfig)_PyInterpreterConfig_INIT
2008+
: (_PyInterpreterConfig)_PyInterpreterConfig_LEGACY_INIT;
20122009
// XXX Possible GILState issues?
20132010
PyThreadState *tstate = _Py_NewInterpreterFromConfig(&config);
20142011
PyThreadState_Swap(save_tstate);

0 commit comments

Comments
 (0)