[New-bugs-announce] [issue40839] Disallow calling PyDict_GetItem() with the GIL released

STINNER Victor report at bugs.python.org
Mon Jun 1 14:46:37 EDT 2020


New submission from STINNER Victor <vstinner at python.org>:

For historical reasons, it was allowed to call the PyDict_GetItem() function with the GIL released.
 
I propose to change PyDict_GetItem() to fail with a fatal error if it's called with the GIL released.

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.

In Python 3.8 and then 3.9, some functions started to crash when called without holding the GIL. It caused some bad surprises to C extension modules authors. Example: gdb developers with bpo-40826. In my opinion, holding the GIL was always required even if it is not very explicit in the documentation of the C API (only the documentation of few functions are explicit about the GIL).

----------
components: C API
messages: 370572
nosy: vstinner
priority: normal
severity: normal
status: open
title: Disallow calling PyDict_GetItem() with the GIL released
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40839>
_______________________________________


More information about the New-bugs-announce mailing list