test_run.py does from idlelib import run, so running it evicts tkinter.commondialog from sys.modules. A later import re-executes commondialog, creating a second Dialog class.
The common-dialog tests cache the class at load (from tkinter.commondialog import Dialog) and patch it with swap_attr(Dialog, '_test_callback', ...). After the re-import that cached class is stale, so the patch misses the class the live dialog uses, and test_colorchooser.test_askcolor opens the real modal color chooser and hangs:
./python -m test -uall test_tkinter test_ttk test_idle
It only fails when test_run runs before the dialog test in the same process (not under -j).
Importing a module shouldn't mutate global sys.modules; idlelib.run should do the scrub only when launched as the subprocess main, not at import.
I agree. The purpose is to prevent user code running from IDLE passing when it should fail due to missing tkinter submodule imports. I will add the needed clause to the existing if guard.
Module run is not launched as subprocess main. It is imported with __import__('idlelib.run'), avoiding binding it in main. (Function run.main is run by appending .run.main() to the import.) So I 'guarded' the scrubbing by wrapping it in a function called at the top of main.
Activity
terryjreedy commented on Sep 3, 2026
I agree. The purpose is to prevent user code running from IDLE passing when it should fail due to missing tkinter submodule imports. I will add the needed clause to the existing if guard.
terryjreedy commented on Sep 4, 2026
Module run is not launched as subprocess main. It is imported with __import__('idlelib.run'), avoiding binding it in main. (Function run.main is run by appending .run.main() to the import.) So I 'guarded' the scrubbing by wrapping it in a function called at the top of main.
gh-156896: Stop scrubbing tkinker submodules upon idlelib.run import (#…
[3.14] gh-156896: Stop scrubbing tkinter submodules upon idlelib.run …
[3.13] gh-156896: Stop scrubbing tkinter submodules upon idlelib.run …
pythongh-156896: Stop scrubbing tkinker submodules upon idlelib.run i…
serhiy-storchaka commented on Sep 15, 2026
Fixed in main by #156915 and backported to 3.13 (#156960) and 3.14 (#156959). The 3.15 backport #156958 is waiting for the release manager.
[3.15] gh-156896: Stop scrubbing tkinter submodules upon idlelib.run …