https://github.com/python/cpython/commit/bb5bf2422618506dca45912bd174d02b40b4113c
commit: bb5bf2422618506dca45912bd174d02b40b4113c
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: encukou <[email protected]>
date: 2024-05-10T14:20:22Z
summary:

[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 db5af7da092409030c9fbe0a3a986bd0ee441b8b)

Co-authored-by: Sam Gross <[email protected]>

files:
A Misc/NEWS.d/next/C API/2024-05-08-20-13-00.gh-issue-118789.m88uUa.rst
M Include/cpython/weakrefobject.h
M Include/internal/pycore_weakref.h

diff --git a/Include/cpython/weakrefobject.h b/Include/cpython/weakrefobject.h
index 9a796098c6b48f..dcca166d7357cc 100644
--- a/Include/cpython/weakrefobject.h
+++ b/Include/cpython/weakrefobject.h
@@ -40,6 +40,8 @@ struct _PyWeakReference {
 #endif
 };
 
+PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
+
 Py_DEPRECATED(3.13) static inline PyObject* PyWeakref_GET_OBJECT(PyObject 
*ref_obj)
 {
     PyWeakReference *ref;
diff --git a/Include/internal/pycore_weakref.h 
b/Include/internal/pycore_weakref.h
index e057a27340f718..cc6c7ff9a9b438 100644
--- a/Include/internal/pycore_weakref.h
+++ b/Include/internal/pycore_weakref.h
@@ -111,8 +111,6 @@ extern Py_ssize_t _PyWeakref_GetWeakrefCount(PyObject *obj);
 // intact.
 extern void _PyWeakref_ClearWeakRefsExceptCallbacks(PyObject *obj);
 
-extern void _PyWeakref_ClearRef(PyWeakReference *self);
-
 PyAPI_FUNC(int) _PyWeakref_IsDead(PyObject *weakref);
 
 #ifdef __cplusplus
diff --git a/Misc/NEWS.d/next/C 
API/2024-05-08-20-13-00.gh-issue-118789.m88uUa.rst b/Misc/NEWS.d/next/C 
API/2024-05-08-20-13-00.gh-issue-118789.m88uUa.rst
new file mode 100644
index 00000000000000..a2acc16b2c1d01
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2024-05-08-20-13-00.gh-issue-118789.m88uUa.rst     
@@ -0,0 +1,2 @@
+Restore ``_PyWeakref_ClearRef`` that was previously removed in Python 3.13
+alpha 1.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to