]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-100227: Make the Global Interned Dict Safe for Isolated Interpreters (gh-102925)
authorEric Snow <ericsnowcurrently@gmail.com>
Thu, 23 Mar 2023 00:30:04 +0000 (18:30 -0600)
committerGitHub <noreply@github.com>
Thu, 23 Mar 2023 00:30:04 +0000 (18:30 -0600)
commit87be8d95228ee95de9045cf2952311d20dc5de45
tree2f7172f22aaae687b17a04de208d79b757f68a7f
parent8709697292c67254ba836d7e88d1eba08c4a351a
gh-100227: Make the Global Interned Dict Safe for Isolated Interpreters (gh-102925)

This is effectively two changes.  The first (the bulk of the change) is where we add _Py_AddToGlobalDict() (and _PyRuntime.cached_objects.main_tstate, etc.).  The second (much smaller) change is where we update PyUnicode_InternInPlace() to use _Py_AddToGlobalDict() instead of calling PyDict_SetDefault() directly.

Basically, _Py_AddToGlobalDict() is a wrapper around PyDict_SetDefault() that should be used whenever we need to add a value to a runtime-global dict object (in the few cases where we are leaving the container global rather than moving it to PyInterpreterState, e.g. the interned strings dict).  _Py_AddToGlobalDict() does all the necessary work to make sure the target global dict is shared safely between isolated interpreters.  This is especially important as we move the obmalloc state to each interpreter (gh-101660), as well as, potentially, the GIL (PEP 684).

https://github.com/python/cpython/issues/100227
Include/internal/pycore_global_objects.h
Include/internal/pycore_pystate.h
Include/internal/pycore_runtime_init.h
Include/internal/pycore_unicodeobject.h
Objects/unicodeobject.c
Python/pylifecycle.c
Python/pystate.c