Skip to content

Commit bb5bf24

Browse files
[3.13] gh-118789: Restore hidden _PyWeakref_ClearRef (GH-118797) (GH-118903)
gh-118789: Restore hidden `_PyWeakref_ClearRef` (GH-118797) _PyWeakref_ClearRef was previously exposed in the public C-API, although it begins with an underscore and is not documented. It's used by a few C-API extensions. There is currently no alternative public API that can replace its use. _PyWeakref_ClearWeakRefsExceptCallbacks is the only thread-safe way to use _PyWeakref_ClearRef in the free-threaded build. This exposes the C symbol, but does not make the API public. (cherry picked from commit db5af7d) Co-authored-by: Sam Gross <colesbury@gmail.com>
1 parent 93fce2d commit bb5bf24

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Include/cpython/weakrefobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ struct _PyWeakReference {
4040
#endif
4141
};
4242

43+
PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
44+
4345
Py_DEPRECATED(3.13) static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj)
4446
{
4547
PyWeakReference *ref;

Include/internal/pycore_weakref.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ extern Py_ssize_t _PyWeakref_GetWeakrefCount(PyObject *obj);
111111
// intact.
112112
extern void _PyWeakref_ClearWeakRefsExceptCallbacks(PyObject *obj);
113113

114-
extern void _PyWeakref_ClearRef(PyWeakReference *self);
115-
116114
PyAPI_FUNC(int) _PyWeakref_IsDead(PyObject *weakref);
117115

118116
#ifdef __cplusplus
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Restore ``_PyWeakref_ClearRef`` that was previously removed in Python 3.13
2+
alpha 1.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy