Commit f3c6589e authored by Ned Deily's avatar Ned Deily

Issue #18270: Prevent possible IDLE AttributeError on OS X when no initial

shell window is present. (Original patch by Terry Reedy)
parent ea6854a9
...@@ -1534,20 +1534,22 @@ def main(): ...@@ -1534,20 +1534,22 @@ def main():
args.remove(filename) args.remove(filename)
if not args: if not args:
flist.new() flist.new()
if enable_shell: if enable_shell:
shell = flist.open_shell() shell = flist.open_shell()
if not shell: if not shell:
return # couldn't open shell return # couldn't open shell
if macosxSupport.runningAsOSXApp() and flist.dict: if macosxSupport.runningAsOSXApp() and flist.dict:
# On OSX: when the user has double-clicked on a file that causes # On OSX: when the user has double-clicked on a file that causes
# IDLE to be launched the shell window will open just in front of # IDLE to be launched the shell window will open just in front of
# the file she wants to see. Lower the interpreter window when # the file she wants to see. Lower the interpreter window when
# there are open files. # there are open files.
shell.top.lower() shell.top.lower()
else:
shell = flist.pyshell
shell = flist.pyshell # Handle remaining options. If any of these are set, enable_shell
# handle remaining options: # was set also, so shell must be true to reach here.
if debug: if debug:
shell.open_debugger() shell.open_debugger()
if startup: if startup:
...@@ -1555,7 +1557,7 @@ def main(): ...@@ -1555,7 +1557,7 @@ def main():
os.environ.get("PYTHONSTARTUP") os.environ.get("PYTHONSTARTUP")
if filename and os.path.isfile(filename): if filename and os.path.isfile(filename):
shell.interp.execfile(filename) shell.interp.execfile(filename)
if shell and cmd or script: if cmd or script:
shell.interp.runcommand("""if 1: shell.interp.runcommand("""if 1:
import sys as _sys import sys as _sys
_sys.argv = %r _sys.argv = %r
...@@ -1566,13 +1568,14 @@ def main(): ...@@ -1566,13 +1568,14 @@ def main():
elif script: elif script:
shell.interp.prepend_syspath(script) shell.interp.prepend_syspath(script)
shell.interp.execfile(script) shell.interp.execfile(script)
elif shell:
# Check for problematic OS X Tk versions and print a warning message # If there is a shell window and no cmd or script in progress,
# in the IDLE shell window; this is less intrusive than always opening # check for problematic OS X Tk versions and print a warning
# a separate window. # message in the IDLE shell window; this is less intrusive
tkversionwarning = macosxSupport.tkVersionWarning(root) # than always opening a separate window.
if tkversionwarning: tkversionwarning = macosxSupport.tkVersionWarning(root)
shell.interp.runcommand(''.join(("print('", tkversionwarning, "')"))) if tkversionwarning:
shell.interp.runcommand("print('%s')" % tkversionwarning)
while flist.inversedict: # keep IDLE running while files are open. while flist.inversedict: # keep IDLE running while files are open.
root.mainloop() root.mainloop()
......
...@@ -109,7 +109,10 @@ Library ...@@ -109,7 +109,10 @@ Library
IDLE IDLE
---- ----
- Issue #19481: print() of string subclass instance in IDLE no more hangs. - Issue #19481: print() of string subclass instance in IDLE no longer hangs.
- Issue #18270: Prevent possible IDLE AttributeError on OS X when no initial
shell window is present.
Tests Tests
----- -----
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment