Skip to content

[3.13] gh-118789: Add PyUnstable_Object_ClearWeakRefsNoCallbacks (GH-118807) - #120695

Merged
colesbury merged 1 commit into
python:3.13from
miss-islington:backport-e8752d7-3.13
Jun 18, 2024
Merged

[3.13] gh-118789: Add PyUnstable_Object_ClearWeakRefsNoCallbacks (GH-118807)#120695
colesbury merged 1 commit into
python:3.13from
miss-islington:backport-e8752d7-3.13

Conversation

@miss-islington

@miss-islingtonmiss-islington commented Jun 18, 2024

Copy link
Copy Markdown
Contributor

This exposes PyUnstable_Object_ClearWeakRefsNoCallbacks as an unstable
C-API function to provide a thread-safe mechanism for clearing weakrefs
without executing callbacks.

Some C-API extensions need to clear weakrefs without calling callbacks,
such as after running finalizers like we do in subtype_dealloc.
Previously they could use _PyWeakref_ClearRef on each weakref, but
that's not thread-safe in the free-threaded build.

(cherry picked from commit e8752d7)

Co-authored-by: Sam Gross colesbury@gmail.com
Co-authored-by: Petr Viktorin encukou@gmail.com


📚 Documentation preview 📚: https://cpython-previews--120695.org.readthedocs.build/

…thonGH-118807)
This exposes `PyUnstable_Object_ClearWeakRefsNoCallbacks` as an unstable
C-API function to provide a thread-safe mechanism for clearing weakrefs
without executing callbacks.
Some C-API extensions need to clear weakrefs without calling callbacks,
such as after running finalizers like we do in subtype_dealloc.
Previously they could use `_PyWeakref_ClearRef` on each weakref, but
that's not thread-safe in the free-threaded build.
(cherry picked from commit e8752d7)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@miss-islington@colesbury