gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators by DinoV · Pull Request #118454 · python/cpython

@bedevere-app bot mentioned this pull request

May 1, 2024

@DinoV

Makes setting an attribute on a class and signaling type modified atomic
Avoid adding re-entrancy exposing the type cache in an inconsistent state by decrefing after type is updated

colesbury

@DinoV DinoV marked this pull request as ready for review

May 1, 2024 20:39

@DinoV

Fix some formatting
Add news blurb
Use PyDictObject * more
Rename _PyDict_GetItemRef_LockHeld to _PyDict_GetItemRef_Unicode_LockHeld
Reduce iterations in test
Expose _PyObject_SetAttributeErrorContext for attaching context

@DinoV

@colesbury colesbury changed the title [gh-118362] Fix thread safety around lookups from the type cache in the face of concurrent mutators gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators

May 2, 2024

colesbury

colesbury

@DinoV

colesbury

@DinoV DinoV mentioned this pull request

May 6, 2024

SonicField pushed a commit to SonicField/cpython that referenced this pull request

May 8, 2024
… in the face of concurrent mutators (python#118454)

Add _PyType_LookupRef and use incref before setting attribute on type
Makes setting an attribute on a class and signaling type modified atomic
Avoid adding re-entrancy exposing the type cache in an inconsistent state by decrefing after type is updated

@DinoV DinoV deleted the nogil_type_crash branch

May 31, 2024 18:22

filmor added a commit to pythonnet/pythonnet that referenced this pull request

Dec 7, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454

filmor added a commit to pythonnet/pythonnet that referenced this pull request

Dec 8, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454

filmor added a commit to pythonnet/pythonnet that referenced this pull request

Dec 8, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454

filmor added a commit to pythonnet/pythonnet that referenced this pull request

Dec 8, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454

filmor added a commit to pythonnet/pythonnet that referenced this pull request

Dec 8, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454

filmor added a commit to pythonnet/pythonnet that referenced this pull request

Dec 9, 2025
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454

filmor added a commit to pythonnet/pythonnet that referenced this pull request

Feb 24, 2026
Python 3.14 introduced a new assertion that prevents us from using
PyObject_GenericSetAttr directly in our meta type. To work around
this, we manipulate the type dict directly.

This workaround is a simplified variant of Cython's workaround from
cython/cython#6325.

The relevant Python change is in
python/cpython#118454