Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e72b90e

Browse files
committed
Issue #18270: merge from 3.3
2 parents 7f7f3d7 + f3c6589 commit e72b90e

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

Lib/idlelib/PyShell.py

100644100755
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,28 +1540,30 @@ def main():
15401540
args.remove(filename)
15411541
if not args:
15421542
flist.new()
1543+
15431544
if enable_shell:
15441545
shell = flist.open_shell()
15451546
if not shell:
15461547
return # couldn't open shell
1547-
15481548
if macosxSupport.runningAsOSXApp() and flist.dict:
15491549
# On OSX: when the user has double-clicked on a file that causes
15501550
# IDLE to be launched the shell window will open just in front of
15511551
# the file she wants to see. Lower the interpreter window when
15521552
# there are open files.
15531553
shell.top.lower()
1554+
else:
1555+
shell = flist.pyshell
15541556

1555-
shell = flist.pyshell
1556-
# handle remaining options:
1557+
# Handle remaining options. If any of these are set, enable_shell
1558+
# was set also, so shell must be true to reach here.
15571559
if debug:
15581560
shell.open_debugger()
15591561
if startup:
15601562
filename = os.environ.get("IDLESTARTUP") or \
15611563
os.environ.get("PYTHONSTARTUP")
15621564
if filename and os.path.isfile(filename):
15631565
shell.interp.execfile(filename)
1564-
if shell and cmd or script:
1566+
if cmd or script:
15651567
shell.interp.runcommand("""if 1:
15661568
import sys as _sys
15671569
_sys.argv = %r
@@ -1572,13 +1574,14 @@ def main():
15721574
elif script:
15731575
shell.interp.prepend_syspath(script)
15741576
shell.interp.execfile(script)
1575-
1576-
# Check for problematic OS X Tk versions and print a warning message
1577-
# in the IDLE shell window; this is less intrusive than always opening
1578-
# a separate window.
1579-
tkversionwarning = macosxSupport.tkVersionWarning(root)
1580-
if tkversionwarning:
1581-
shell.interp.runcommand(''.join(("print('", tkversionwarning, "')")))
1577+
elif shell:
1578+
# If there is a shell window and no cmd or script in progress,
1579+
# check for problematic OS X Tk versions and print a warning
1580+
# message in the IDLE shell window; this is less intrusive
1581+
# than always opening a separate window.
1582+
tkversionwarning = macosxSupport.tkVersionWarning(root)
1583+
if tkversionwarning:
1584+
shell.interp.runcommand("print('%s')" % tkversionwarning)
15821585

15831586
while flist.inversedict: # keep IDLE running while files are open.
15841587
root.mainloop()

Misc/NEWS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ Library
131131
IDLE
132132
----
133133

134-
- Issue #19481: print() of string subclass instance in IDLE no more hangs.
134+
- Issue #19481: print() of string subclass instance in IDLE no longer hangs.
135+
136+
- Issue #18270: Prevent possible IDLE AttributeError on OS X when no initial
137+
shell window is present.
135138

136139
Tests
137140
-----

0 commit comments

Comments
 (0)