FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.15] gh-156896: Stop scrubbing tkinter submodules upon idlelib.run import (GH-156915) by serhiy-storchaka · Pull Request #156958 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
27 changes: 17 additions & 10 deletions Lib/idlelib/run.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" idlelib.run

Simplified, pyshell.ModifiedInterpreter spawns a subprocess with
Simplified: pyshell.ModifiedInterpreter spawns a subprocess with
f'''{sys.executable} -c "__import__('idlelib.run').run.main()"'''
'.run' is needed because __import__ returns idlelib, not idlelib.run.
"""
Expand All @@ -26,18 +26,23 @@
from idlelib import rpc # multiple objects
from idlelib import stackviewer # StackTreeItem
from idlelib import util # fix_scaling
import __main__
import __main__ # self.locals in Executive.__init__.

import tkinter # Use tcl and, if startup fails, messagebox.
if not hasattr(sys.modules['idlelib.run'], 'firstrun'):
# Undo modifications of tkinter by idlelib imports; see bpo-25507.

def scrub_tkinter_submodules(): # Call in main when starting user process.
# Undo modifications of tkinter by idlelib imports; see gh-69693.
# Which of these submodules got imported (and thus added as a tkinter
# attribute) depends on what idlelib pulled in, so tolerate missing
# ones rather than assuming a fixed set; see gh-59396.
for mod in ('simpledialog', 'messagebox', 'font',
'dialog', 'filedialog', 'commondialog',
'ttk'):
delattr(tkinter, mod)
del sys.modules['tkinter.' + mod]
# Avoid AttributeError if run again; see bpo-37038.
sys.modules['idlelib.run'].firstrun = False
try:
delattr(tkinter, mod)
del sys.modules['tkinter.' + mod]
except (AttributeError, KeyError):
pass

LOCALHOST = '127.0.0.1'

Expand Down Expand Up @@ -133,6 +138,9 @@ def main(del_exitfunc=False):
register and unregister themselves.

"""

scrub_tkinter_submodules()

global exit_now
global quitting
global no_exitfunc
Expand Down Expand Up @@ -699,8 +707,7 @@ def stackviewer(self, flist_oid=None):
item = stackviewer.StackTreeItem(exc, flist)
return debugobj_r.remote_object_tree_item(item)


if __name__ == '__main__':
if __name__ == '__main__': # __name__ is 'idlelib.run' in user subprocess.
from unittest import main
main('idlelib.idle_test.test_run', verbosity=2)

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stop deleting tkinter submodules when idlelib.run is imported.
Loading

Back | FazBrowse Home | New Git URL