]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-80937: Fix memory leak in tkinter createcommand (GH-152294)
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 26 Jun 2026 18:52:10 +0000 (21:52 +0300)
committerGitHub <noreply@github.com>
Fri, 26 Jun 2026 18:52:10 +0000 (21:52 +0300)
commitbbf7786a904e558a15d01475356167e29b2e3708
tree7db41104d0696b2eea0e0193afb6bfdcccb9f763
parent9626ef87f42fca564c3a74109b370d38076a79da
gh-80937: Fix memory leak in tkinter createcommand (GH-152294)

A command created with createcommand() held a strong reference to the
interpreter, forming an uncollectable cycle (interpreter -> command ->
interpreter) that kept the interpreter and the callback alive until the
command was removed with deletecommand() or destroy().  The command now
borrows the reference; it cannot outlive the interpreter, which deletes its
commands when finalized.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Lib/test/test_tkinter/test_misc.py
Misc/NEWS.d/next/Library/2026-06-26-13-10-00.gh-issue-80937.Hq3mNp.rst [new file with mode: 0644]
Modules/_tkinter.c