From bdc40ca28841bf30b1f629660f9115f874b89bf7 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 19 Oct 2026 13:41:28 -0700 Subject: [PATCH] gh-159739: Track group records for cyclic garbage collection Backport to 3.15 and 3.14. --- .../next/Library/2026-10-19-20-38-17.gh-issue-159739.bc65da.rst | 2 ++ Modules/grpmodule.c | 1 + 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-10-19-20-38-17.gh-issue-159739.bc65da.rst diff --git a/Misc/NEWS.d/next/Library/2026-10-19-20-38-17.gh-issue-159739.bc65da.rst b/Misc/NEWS.d/next/Library/2026-10-19-20-38-17.gh-issue-159739.bc65da.rst new file mode 100644 index 00000000000000..fd831b6907e777 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-19-20-38-17.gh-issue-159739.bc65da.rst @@ -0,0 +1,2 @@ +Allow cyclic garbage collection to reclaim group records returned by +:mod:`grp`. diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c index fe1d16d8322005..5404250ee7387f 100644 --- a/Modules/grpmodule.c +++ b/Modules/grpmodule.c @@ -111,6 +111,7 @@ mkgrent(PyObject *module, struct group *p) return NULL; } + PyObject_GC_Track(v); return v; }