diff options
| author | Eric Snow <ericsnowcurrently@gmail.com> | 2021-12-07 14:02:17 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-07 14:02:17 -0700 |
| commit | 8262c96bcc1841188866c1b022d9087e89639d98 (patch) | |
| tree | 7f57ca54cf571b95c5fe175fdc7456bbba28b667 /Python/pystate.c | |
| parent | 91b59a3fcdcb93d74bb89cce536f11d2990f655d (diff) | |
| download | cpython-git-8262c96bcc1841188866c1b022d9087e89639d98.tar.gz | |
bpo-46008: Return void from _PyEval_InitState(). (gh-29970)
This falls into the category of keep-allocation-and-initialization separate. It also allows us to use _PyEval_InitState() safely in functions that return void.
https://bugs.python.org/issue46008
Diffstat (limited to 'Python/pystate.c')
| -rw-r--r-- | Python/pystate.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index ba14c9d8af..a0bd05077e 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -225,10 +225,12 @@ PyInterpreterState_New(void) _PyRuntimeState *runtime = &_PyRuntime; interp->runtime = runtime; - if (_PyEval_InitState(&interp->ceval) < 0) { + PyThread_type_lock pending_lock = PyThread_allocate_lock(); + if (pending_lock == NULL) { goto out_of_memory; } + _PyEval_InitState(&interp->ceval, pending_lock); _PyGC_InitState(&interp->gc); PyConfig_InitPythonConfig(&interp->config); _PyType_InitCache(interp); |
