]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #18270: Prevent possible IDLE AttributeError on OS X when no initial
authorNed Deily <nad@acm.org>
Wed, 11 Dec 2013 00:24:01 +0000 (16:24 -0800)
committerNed Deily <nad@acm.org>
Wed, 11 Dec 2013 00:24:01 +0000 (16:24 -0800)
shell window is present. (Original patch by Terry Reedy)

Lib/idlelib/PyShell.py [changed mode: 0644->0755]
Misc/NEWS

old mode 100644 (file)
new mode 100755 (executable)
index f50ca28..6674f4e
@@ -1534,20 +1534,22 @@ def main():
                     args.remove(filename)
             if not args:
                 flist.new()
+
     if enable_shell:
         shell = flist.open_shell()
         if not shell:
             return # couldn't open shell
-
         if macosxSupport.runningAsOSXApp() and flist.dict:
             # 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
             # the file she wants to see. Lower the interpreter window when
             # there are open files.
             shell.top.lower()
+    else:
+        shell = flist.pyshell
 
-    shell = flist.pyshell
-    # handle remaining options:
+    # Handle remaining options. If any of these are set, enable_shell
+    # was set also, so shell must be true to reach here.
     if debug:
         shell.open_debugger()
     if startup:
@@ -1555,7 +1557,7 @@ def main():
                    os.environ.get("PYTHONSTARTUP")
         if filename and os.path.isfile(filename):
             shell.interp.execfile(filename)
-    if shell and cmd or script:
+    if cmd or script:
         shell.interp.runcommand("""if 1:
             import sys as _sys
             _sys.argv = %r
@@ -1566,13 +1568,14 @@ def main():
         elif script:
             shell.interp.prepend_syspath(script)
             shell.interp.execfile(script)
-
-    # Check for problematic OS X Tk versions and print a warning message
-    # in the IDLE shell window; this is less intrusive than always opening
-    # a separate window.
-    tkversionwarning = macosxSupport.tkVersionWarning(root)
-    if tkversionwarning:
-        shell.interp.runcommand(''.join(("print('", tkversionwarning, "')")))
+    elif shell:
+        # If there is a shell window and no cmd or script in progress,
+        # check for problematic OS X Tk versions and print a warning
+        # message in the IDLE shell window; this is less intrusive
+        # than always opening a separate window.
+        tkversionwarning = macosxSupport.tkVersionWarning(root)
+        if tkversionwarning:
+            shell.interp.runcommand("print('%s')" % tkversionwarning)
 
     while flist.inversedict:  # keep IDLE running while files are open.
         root.mainloop()
index 9026e754cbecefa54ecc5aff9901f9a6a5a34e57..5a94af38367b0d566d732a655d088ea85f1f5b50 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -109,7 +109,10 @@ Library
 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
 -----