8000 Issue #18270: Prevent possible IDLE AttributeError on OS X when no in… · python/cpython@f3c6589 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3c6589

Browse files
committed
Issue #18270: Prevent possible IDLE AttributeError on OS X when no initial
shell window is present. (Original patch by Terry Reedy)
1 parent ea6854a commit f3c6589

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

Lib/idlelib/PyShell.py

100644100755
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,28 +1534,30 @@ def main():
15341534
args.remove(filename)
15351535
if not args:
15361536
flist.new()
1537+
15371538
if enable_shell:
15381539
shell = flist.open_shell()
15391540
if not shell:
15401541
return # couldn't open shell
1541-
15421542
if macosxSupport.runningAsOSXApp() and flist.dict:
15431543
# On OSX: when the user has double-clicked on a file that causes
15441544
# IDLE to be launched the shell window will open just in front of
15451545
# the file she wants to see. Lower the interpreter window when
15461546
# there are open files.
15471547
shell.top.lower()
1548+
else:
1549+
shell = flist.pyshell
15481550

1549-
shell = flist.pyshell
1550-
# handle remaining options:
1551+
# Handle remaining options. If any of these are set, enable_shell
1552+
# was set also, so shell must be true to reach here.
15511553
if debug:
15521554
shell.open_debugger()
15531555
if startup:
15541556
filename = os.environ.get("IDLESTARTUP") or \
15551557
os.environ.get("PYTHONSTARTUP")
15561558
if filename and os.path.isfile(filename):
15571559
shell.interp.execfile(filename)
1558-
if shell and cmd or script:
1560+
if cmd or script:
15591561
shell.interp.runcommand("""if 1:
15601562
import sys as _sys
15611563
_sys.argv = %r
@@ -1566,13 +1568,14 @@ def main():
15661568
elif script:
15671569
shell.interp.prepend_syspath(script)
15681570
shell.interp.execfile(script)
1569-
1570-
# Check for problematic OS X Tk versions and print a warning message
1571-
# in the IDLE shell window; this is less intrusive than always opening
1572-
# a separate window.
1573-
tkversionwarning = macosxSupport.tkVersionWarning(root)
1574-
if tkversionwarning:
1575-
shell.interp.runcommand(''.join(("print('", tkversionwarning, "')")))
1571+
elif shell:
1572+
# If there is a shell window and no cmd or script in progress,
1573+
# check for problematic OS X Tk versions and print a warning
1574+
# message in the IDLE shell window; this is less intrusive
1575+
# than always opening a separate window.
1576+
tkversionwarning = macosxSupport.tkVersionWarning(root)
1577+
if tkversionwarning:
1578+
shell.interp.runcommand("print('%s')" % tkversionwarning)
15761579

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

Misc/NEWS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ Library
109109
IDLE
110110
----
111111

112-
- Issue #19481: print() of string subclass instance in IDLE no more hangs.
112+
- Issue #19481: print() of string subclass instance in IDLE no longer hangs.
113+
114+
- Issue #18270: Prevent possible IDLE AttributeError on OS X when no initial
115+
shell window is present.
113116

114117
Tests
115118
-----

0 commit comments

Comments
 (0)
0