Make _struct
module thread-safe in --disable-gil
builds
#112062
Closed
Labels
3.13
bugs and security fixes
extension-modules
C modules in the Modules dir
topic-free-threading
type-feature
A feature request or enhancement
Feature or enhancement
The
_struct
module has a few small issues:PyDict_GetItemWithError
returns a borrowed reference (should usePyDict_GetItemRef
)state->cache
is lazily created; we should instead create it during_structmodule_exec
state->cache
to be an immutable reference to a mutable dict. (Thedict
will be thread-safe.) UsePyDict_Clear
to empty the dict instead of clearing the reference.See the commit from the
nogil-3.12
fork for context: colesbury/nogil-3.12@ada9b73feb. Note that in CPython the relevant function isPyDict_GetItemRef
notPyDict_FetchItemWithError
.Linked PRs
_struct
module thread-safe in--disable-gil
builds #112094The text was updated successfully, but these errors were encountered: