-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_pyrepl: test_cursor_back_write() blocks on input_hook() when tests are run sequentially #121008
Comments
Reproducer with less tests:
|
I cannot reproduce on Windows. After some time, the test call above hung until I hit return, then it was a success. The apparently offending chain of events is that test_idle runs (idlelib.idle_test.)test_run which imports idlelib.run which calls tkinter.Tcl which at top level calls into _tkinter which sets tcl to get tk events. Idlelib.run is the only place IDLE calls tkinter.Tcl, but I suspect that calls to _tkinter from tkinter.tk do the same. However, IDLE test that call tk() do so explicitly and later call root.destroy(). Since Tcl.destroy exists, a fix might be to add the following top level cleanup function near the top of test_run.
I'm off to bed. |
If I just add tearDownModule() to Lib/idlelib/idle_test/test_run.py, I get:
|
Tcl() returns a Tk object created with useTk False instead of True. So the tkinter destroy method is the one called normally.
But this and perhaps other methods are not valid for such object. This is a tkinter bug. Alternate try: in idlelib.run, replace lines 94-100
with
This might not be a permanent solution but should work. I cannot test for several hours. |
When testing IDLE, don't create a Tk to avoid side effects such as installing a PyOS_InputHook hook.
I wrote a fix based on @terryjreedy's recipe and it works for me! |
When testing IDLE, don't create a Tk to avoid side effects such as installing a PyOS_InputHook hook.
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 <[email protected]>
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 <[email protected]>
Fixed by 44eafd6. |
Thank you @terryjreedy for the fix! |
If I ever want to unittest run's handling of interactive tkinter calls, I will ask Serhiy to add a DisableEventHook to _tkinter, if not there already, and make it accessible from Python code, perhaps by making Tcl a subclass that defines a destroy method that works. |
When testing IDLE, don't create a Tk to avoid side effects such as installing a PyOS_InputHook hook.
When testing IDLE, don't create a Tk to avoid side effects such as installing a PyOS_InputHook hook.
When testing IDLE, don't create a Tk to avoid side effects such as installing a PyOS_InputHook hook.
Command:
gdb:
Linked PRs
The text was updated successfully, but these errors were encountered: