From a4665b5067266becc2ec3f08ec7246199aa5d086 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 14 Jan 2026 21:55:11 +0200 Subject: [PATCH] Fix refleaks in new unicodedata classes added in gh-74902 (GH-143843) --- Modules/unicodedata.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index e34fb13b69a..84b5659f051 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -1875,9 +1875,11 @@ typedef struct { static void Segment_dealloc(PyObject *self) { + PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); Py_DECREF(((SegmentObject *)self)->string); - PyObject_GC_Del(self); + tp->tp_free(self); + Py_DECREF(tp); } static int @@ -1949,9 +1951,11 @@ typedef struct { static void GBI_dealloc(PyObject *self) { + PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); Py_DECREF(((GraphemeBreakIterator *)self)->iter.str); - PyObject_GC_Del(self); + tp->tp_free(self); + Py_DECREF(tp); } static int