]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-94207: Fix struct module leak (GH-94239)
authorMark Dickinson <mdickinson@enthought.com>
Sat, 25 Jun 2022 14:11:58 +0000 (15:11 +0100)
committerGitHub <noreply@github.com>
Sat, 25 Jun 2022 14:11:58 +0000 (15:11 +0100)
commit6b865349aae47b90f9ef0b98f3fe3720c2f05601
tree9896212e12df59b30f9302fdeed61895f0600e3e
parent944c7d8a8561d4b637af5c128df1d8d7570ccb46
gh-94207: Fix struct module leak (GH-94239)

Make _struct.Struct a GC type

This fixes a memory leak in the _struct module, where as soon
as a Struct object is stored in the cache, there's a cycle from
the _struct module to the cache to Struct objects to the Struct
type back to the module. If _struct.Struct is not gc-tracked, that
cycle is never collected.

This PR makes _struct.Struct GC-tracked, and adds a regression test.
Lib/test/test_struct.py
Misc/NEWS.d/next/Library/2022-06-24-19-23-59.gh-issue-94207.VhS1eS.rst [new file with mode: 0644]
Modules/_struct.c