[Python-checkins] Statically initialize _PyRuntimeState fields. (gh-30588)
ericsnowcurrently
webhook-mailer at python.org
Thu Jan 13 18:33:52 EST 2022
https://github.com/python/cpython/commit/b8ddf7e794e5316981016d6d014862e3c4ce149a
commit: b8ddf7e794e5316981016d6d014862e3c4ce149a
branch: main
author: Eric Snow <ericsnowcurrently at gmail.com>
committer: ericsnowcurrently <ericsnowcurrently at gmail.com>
date: 2022-01-13T16:33:40-07:00
summary:
Statically initialize _PyRuntimeState fields. (gh-30588)
https://bugs.python.org/issue45953
files:
M Include/internal/pycore_runtime_init.h
M Python/pystate.c
diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h
index e35c696610b94..fc768ff5d053f 100644
--- a/Include/internal/pycore_runtime_init.h
+++ b/Include/internal/pycore_runtime_init.h
@@ -17,6 +17,17 @@ extern "C" {
#define _PyRuntimeState_INIT \
{ \
+ .gilstate = { \
+ .check_enabled = 1, \
+ /* A TSS key must be initialized with Py_tss_NEEDS_INIT \
+ in accordance with the specification. */ \
+ .autoTSSkey = Py_tss_NEEDS_INIT, \
+ }, \
+ .interpreters = { \
+ /* This prevents interpreters from getting created \
+ until _PyInterpreterState_Enable() is called. */ \
+ .next_id = -1, \
+ }, \
.global_objects = _Py_global_objects_INIT, \
._main_interpreter = _PyInterpreterState_INIT, \
}
diff --git a/Python/pystate.c b/Python/pystate.c
index e6175852c461c..50b3621896028 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -111,17 +111,7 @@ init_runtime(_PyRuntimeState *runtime,
PyPreConfig_InitPythonConfig(&runtime->preconfig);
- 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;
-
runtime->interpreters.mutex = interpreters_mutex;
- // This prevents interpreters from getting created
- // until _PyInterpreterState_Enable() is called.
- runtime->interpreters.next_id = -1;
runtime->xidregistry.mutex = xidregistry_mutex;
More information about the Python-checkins
mailing list