Bug report
idlelib/run.py scrubs tkinter at import time (bpo-25507, gh-59396):
for mod in ('simpledialog', 'messagebox', 'font', 'dialog', 'filedialog', 'commondialog', 'ttk'):
try:
delattr(tkinter, mod)
del sys.modules['tkinter.' + mod]
except (AttributeError, KeyError):
pass
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.
Linked PRs
Bug report
idlelib/run.pyscrubs tkinter at import time (bpo-25507, gh-59396):test_run.pydoesfrom idlelib import run, so running it evictstkinter.commondialogfromsys.modules. A later import re-executescommondialog, creating a secondDialogclass.The common-dialog tests cache the class at load (
from tkinter.commondialog import Dialog) and patch it withswap_attr(Dialog, '_test_callback', ...). After the re-import that cached class is stale, so the patch misses the class the live dialog uses, andtest_colorchooser.test_askcoloropens the real modal color chooser and hangs:It only fails when
test_runruns before the dialog test in the same process (not under-j).Importing a module shouldn't mutate global
sys.modules;idlelib.runshould do the scrub only when launched as the subprocess main, not at import.Linked PRs