Skip to content

Commit bdcc738

Browse files
[3.13] gh-121008: Fix idlelib.run tests (GH-121046) (#121049)
gh-121008: Fix idlelib.run tests (GH-121046) When testing IDLE, don't create a Tk to avoid side effects such as installing a PyOS_InputHook hook. (cherry picked from commit 44eafd6) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 7db14f1 commit bdcc738

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Lib/idlelib/run.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,20 @@ def capture_warnings(capture):
9191
_warnings_showwarning = None
9292

9393
capture_warnings(True)
94-
tcl = tkinter.Tcl()
9594

96-
def handle_tk_events(tcl=tcl):
97-
"""Process any tk events that are ready to be dispatched if tkinter
98-
has been imported, a tcl interpreter has been created and tk has been
99-
loaded."""
100-
tcl.eval("update")
95+
if idlelib.testing:
96+
# gh-121008: When testing IDLE, don't create a Tk object to avoid side
97+
# effects such as installing a PyOS_InputHook hook.
98+
def handle_tk_events():
99+
pass
100+
else:
101+
tcl = tkinter.Tcl()
102+
103+
def handle_tk_events(tcl=tcl):
104+
"""Process any tk events that are ready to be dispatched if tkinter
105+
has been imported, a tcl interpreter has been created and tk has been
106+
loaded."""
107+
tcl.eval("update")
101108

102109
# Thread shared globals: Establish a queue between a subthread (which handles
103110
# the socket) and the main thread (which runs user code), plus global

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy