Title: Importing idlelib.run deletes tkinter dialog submodules from sys.modules · Issue #156896 · python/cpython · GitHub
Open Graph Title: Importing idlelib.run deletes tkinter dialog submodules from sys.modules · Issue #156896 · python/cpython
X Title: Importing idlelib.run deletes tkinter dialog submodules from sys.modules · Issue #156896 · python/cpython
Description: 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]...
Open Graph Description: 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...
X Description: Bug report idlelib/run.py scrubs tkinter at import time (bpo-25507, gh-59396): for mod in ('simpledialog', 'messagebox', 'font', 'dialog', 'filedialog', '...
Opengraph URL: https://github.com/python/cpython/issues/156896
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Importing idlelib.run deletes tkinter dialog submodules from sys.modules","articleBody":"# Bug report\n\n`idlelib/run.py` scrubs tkinter at import time (bpo-25507, gh-59396):\n\n```python\nfor mod in ('simpledialog', 'messagebox', 'font', 'dialog', 'filedialog', 'commondialog', 'ttk'):\n try:\n delattr(tkinter, mod)\n del sys.modules['tkinter.' + mod]\n except (AttributeError, KeyError):\n pass\n```\n\n`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.\n\nThe 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:\n\n```\n./python -m test -uall test_tkinter test_ttk test_idle\n```\n\nIt only fails when `test_run` runs before the dialog test in the same process (not under `-j`).\n\nImporting a module shouldn't mutate global `sys.modules`; `idlelib.run` should do the scrub only when launched as the subprocess main, not at import.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156915\n* gh-156958\n* gh-156959\n* gh-156960\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2026-09-03T13:28:13Z","url":"https://github.com/python/cpython/issues/156896"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5248a742-3e43-5113-d927-f012c350c0b4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B92C:A99C2:3E00F10:4EBECAE:6B01FA49 |
| html-safe-nonce | 167994c4dcab7b0871c024f88f38ae9ee64850ef1e5875027ec78a4d860e4f47 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTJDOkE5OUMyOjNFMDBGMTA6NEVCRUNBRTo2QjAxRkE0OSIsInZpc2l0b3JfaWQiOiI0NTA3NDcyMzY2ODE2ODUyNTUzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3b10ec57a05322671418626e4942d8647c77a4ce2f0bdfd682c7020eec32b2b8 |
| hovercard-subject-tag | issue:5337254042 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156896/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b2c4d2efb15f23d53f80b4b3575e5a333315fc8a19523e6b75d3c49d1da66502/python/cpython/issues/156896 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b2c4d2efb15f23d53f80b4b3575e5a333315fc8a19523e6b75d3c49d1da66502/python/cpython/issues/156896 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width