From 43ee6ff556a36f63f86f70b30c038e887d958ca4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 20 Oct 2026 10:20:07 -0700 Subject: [PATCH] gh-159739: Track group records for cyclic garbage collection (GH-159778) (cherry picked from commit c2deb791c5381b2c97db4b92e0289ad9c60460ff) Co-authored-by: Jelle Zijlstra Co-authored-by: Jelle Zijlstra --- .../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 000000000000000..fd831b6907e7778 --- /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 652958618a2c4c8..d92f09f592536eb 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; }