diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2024-04-12 22:39:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-12 22:39:27 (GMT) |
commit | eca53620e3ff1f2e7d621360a513ac34a1b35aa3 (patch) | |
tree | ab3c223d633da42d8205ff12d90da8f40b709885 /Objects | |
parent | 30f0643e36d2c9a5849c76ca0b27b748448d0567 (diff) | |
download | cpython-eca53620e3ff1f2e7d621360a513ac34a1b35aa3.zip cpython-eca53620e3ff1f2e7d621360a513ac34a1b35aa3.tar.gz cpython-eca53620e3ff1f2e7d621360a513ac34a1b35aa3.tar.bz2 |
gh-94673: Clarify About Runtime State Related to Static Builtin Types (gh-117761)
Guido pointed out to me that some details about the per-interpreter state for the builtin types aren't especially clear. I'm addressing that by:
* adding a comment explaining that state
* adding some asserts to point out the relationship between each index and the interp/global runtime state
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index a3c1375..1cb5351 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -162,9 +162,14 @@ _PyStaticType_GetState(PyInterpreterState *interp, PyTypeObject *self) static void static_builtin_state_init(PyInterpreterState *interp, PyTypeObject *self) { - if (!static_builtin_index_is_set(self)) { + if (_Py_IsMainInterpreter(interp)) { + assert(!static_builtin_index_is_set(self)); static_builtin_index_set(self, interp->types.num_builtins_initialized); } + else { + assert(static_builtin_index_get(self) == + interp->types.num_builtins_initialized); + } static_builtin_state *state = static_builtin_state_get(interp, self); /* It should only be called once for each builtin type. */ |