Skip to content

_PyWeakref_ClearRef and _PyWeakref_ClearWeakRefsExceptCallbacks should be exposed in 3.13 #118789

Description

@colesbury

_PyWeakref_ClearRef was previously exposed in the public C-API. In 3.13, it was moved to pycore_weakref.h and the symbol is not exposed (i.e., it's extern void instead of PyAPI_FUNC(void).

_PyWeakref_ClearRef is used to clear a single weakref without calling its callback. _PyWeakref_ClearWeakRefsExceptCallbacks is the thread-safe version. If people are using _PyWeakref_ClearRef, we'd rather they use _PyWeakref_ClearWeakRefsExceptCallbacks so that the code is thread-safe in the free-threading build.

One use case is to clear newly added weakrefs after you've called a finalizer, in case your C type does not delegate to subtype_dealloc.

Uses:

At a minimum, we should add PyAPI_FUNC to _PyWeakref_ClearRef and _PyWeakref_ClearWeakRefsExceptCallbacks and consider making _PyWeakref_ClearWeakRefsExceptCallbacks part of the public C API.

Linked PRs

Activity

  1. added 2 commits that reference this issue on May 8, 2024
  2. added a commit that references this issue on May 10, 2024
  3. added a commit that references this issue on May 10, 2024
  4. added a commit that references this issue on May 10, 2024
  5. added 2 commits that reference this issue on Jun 17, 2024
  6. added a commit that references this issue on Jun 18, 2024
  7. added a commit that references this issue on Jun 18, 2024
  8. added a commit that references this issue on Jun 19, 2024
  9. added a commit that references this issue on Jun 30, 2024
  10. added a commit that references this issue on Jul 11, 2024
  11. added a commit that references this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions