8000 bpo-37038: Make idlelib.run runnable; add test clause by terryjreedy · Pull Request #13560 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-37038: Make idlelib.run runnable; add test clause #13560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/idlelib/NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Released on 2019-10-20?
======================================


bpo-37038: Make idlelib.run runnable; add test clause.

bpo-36958: Print any argument other than None or int passed to
SystemExit or sys.exit().

Expand Down
30 changes: 22 additions & 8 deletions Lib/idlelib/run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
""" idlelib.run

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.
"""
import io
import linecache
import queue
Expand All @@ -8,8 +14,6 @@
import threading
import warnings

import tkinter # Tcl, deletions, messagebox if startup fails

from idlelib import autocomplete # AutoComplete, fetch_encodings
from idlelib import calltip # Calltip
from idlelib import debugger_r # start_debugger
Expand All @@ -19,11 +23,16 @@
from idlelib import stackviewer # StackTreeItem
import __main__

for mod in ('simpledialog', 'messagebox', 'font',
'dialog', 'filedialog', 'commondialog',
'ttk'):
delattr(tkinter, mod)
del sys.modules['tkinter.' + mod]
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.
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

LOCALHOST = '127.0.0.1'

Expand Down Expand Up @@ -523,4 +532,9 @@ def stackviewer(self, flist_oid=None):
item = stackviewer.StackTreeItem(flist, tb)
return debugobj_r.remote_object_tree_item(item)

capture_warnings(False) # Make sure turned off; see issue 18081

if __name__ == '__main__':
from unittest import main
main('idlelib.idle_test.test_run', verbosity=2)

capture_warnings(False) # Make sure turned off; see bpo-18081.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make idlelib.run runnable; add test clause.
0