-
-
Notifications
You must be signed in to change notification settings - Fork 37k
Importing idlelib.run deletes tkinter dialog submodules from sys.modules #156896
Copy link
Copy link
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixestestsTests in the Lib/test dirTests in the Lib/test dirtopic-IDLEtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixestestsTests in the Lib/test dirTests in the Lib/test dirtopic-IDLEtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
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