From 10bb5210bce2cc7c22cd5f379cf75349c08e1c89 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 20 Oct 2026 15:18:37 -0700 Subject: [PATCH] gh-159739: Break reference cycles involving property objects Backport to 3.15 and 3.14. --- .../2026-10-20-00-00-00.gh-issue-159739.848b18.rst | 2 ++ Objects/descrobject.c | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-10-20-00-00-00.gh-issue-159739.848b18.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-20-00-00-00.gh-issue-159739.848b18.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-20-00-00-00.gh-issue-159739.848b18.rst new file mode 100644 index 000000000000000..07f842471b4d0f2 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-20-00-00-00.gh-issue-159739.848b18.rst @@ -0,0 +1,2 @@ +Allow the garbage collector to break reference cycles involving property +accessors or names. diff --git a/Objects/descrobject.c b/Objects/descrobject.c index c0af1ed8cad8307..c4e525797d19aeb 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -2007,7 +2007,11 @@ static int property_clear(PyObject *self) { propertyobject *pp = (propertyobject *)self; + Py_CLEAR(pp->prop_get); + Py_CLEAR(pp->prop_set); + Py_CLEAR(pp->prop_del); Py_CLEAR(pp->prop_doc); + Py_CLEAR(pp->prop_name); return 0; }