Skip to content

[3.15] gh-161353: Fix handle leak in test_tcl (GH-161368) - #161650

Open
gpshead wants to merge 1 commit into
python:3.15from
gpshead:backport-2781ffe-3.15
Open

gpshead wants to merge 1 commit into
python:3.15from
gpshead:backport-2781ffe-3.15

Conversation

@gpshead

@gpshead gpshead commented Nov 9, 2026

Copy link
Copy Markdown
Member

Fix handle leaks in test_tcl when the test is run with -R 3:3. Call
explicitly Tcl_FinalizeThread() in test_returning_deeply_nested() to
clean up explicitly per-thread state. The test is run in a thread
because of the @run_with_limited_c_stack() decorator.

On Windows, Tcl_CreateInterp() creates an event in the Tcl notifier
implementation. The event is stored in per-thread state which is only
cleaned up at exit.

Add the private _tkinter._finalize_thread() function.
(cherry picked from commit 2781ffe)

Co-authored-by: Victor Stinner vstinner@python.org

Manual backport notes (3.15): the only conflict was in the generated Modules/clinic/_tkinter.c.h (surrounding context and output checksum differ on 3.15). It was regenerated with the 3.15 Argument Clinic; the generated code is identical to main's. test_tcl passes on 3.15, including with -R 3:3.

Fix handle leaks in test_tcl when the test is run with -R 3:3. Call
explicitly Tcl_FinalizeThread() in test_returning_deeply_nested() to
clean up explicitly per-thread state. The test is run in a thread
because of the @run_with_limited_c_stack() decorator.

On Windows, Tcl_CreateInterp() creates an event in the Tcl notifier
implementation. The event is stored in per-thread state which is only
cleaned up at exit.

Add the private _tkinter._finalize_thread() function.
(cherry picked from commit 2781ffe)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants