diff options
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 55ff64951b..30f214e93d 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -35,7 +35,7 @@ to avoid the expense of doing their own locking). extern "C" { #endif -void +_PyInitError _PyRuntimeState_Init(_PyRuntimeState *runtime) { memset(runtime, 0, sizeof(*runtime)); @@ -46,17 +46,19 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime) _PyEval_Initialize(&runtime->ceval); runtime->gilstate.check_enabled = 1; + /* A TSS key must be initialized with Py_tss_NEEDS_INIT in accordance with the specification. */ - { - Py_tss_t initial = Py_tss_NEEDS_INIT; - runtime->gilstate.autoTSSkey = initial; - } + Py_tss_t initial = Py_tss_NEEDS_INIT; + runtime->gilstate.autoTSSkey = initial; runtime->interpreters.mutex = PyThread_allocate_lock(); - if (runtime->interpreters.mutex == NULL) - Py_FatalError("Can't initialize threads for interpreter"); + if (runtime->interpreters.mutex == NULL) { + return _Py_INIT_ERR("Can't initialize threads for interpreter"); + } + runtime->interpreters.next_id = -1; + return _Py_INIT_OK(); } void |