[issue40839] Disallow calling PyDict_GetItem() with the GIL released
STINNER Victor
report at bugs.python.org
Mon Jun 1 14:56:17 EDT 2020
STINNER Victor <vstinner at python.org> added the comment:
Current comment in Objects/dictobject.c:
/* We can arrive here with a NULL tstate during initialization: try
running "python -Wi" for an example related to string interning.
Let's just hope that no exception occurs then... This must be
_PyThreadState_GET() and not PyThreadState_Get() because the latter
abort Python if tstate is NULL. */
PyDict_GetItem() is no longer called before Py_Initialize(). I reworked the Python startup to no longer use Python objects before Py_Initialize(): see PEP 587 (PyConfig).
> To help C extension modules authors, I propose to keep a check at the runtime even in release build. Later, we may drop this check in release mode and only keep it in debug mode.
Hum, since the whole test pass with the change and it was not documented that it was possible to call the function with the GIL released, I changed my mind and only kept the runtime check in debug mode.
----------
nosy: +eric.snow, ncoghlan
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40839>
_______________________________________
More information about the Python-bugs-list
mailing list