Skip to content

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

Merged
vstinner merged 1 commit into
python:3.15from
gpshead:backport-2781ffe-3.15
Nov 9, 2026
Merged

vstinner merged 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>

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinner
vstinner merged commit e7dccf0 into python:3.15 Nov 9, 2026
55 checks passed
@vstinner

vstinner commented Nov 9, 2026

Copy link
Copy Markdown
Member

Thanks for the backport.

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