Skip to content

Commit 08107c0

Browse files
author
kurt.kaiser
committed
Patch #1540892: site.py Quitter() class attempts to close sys.stdin
before raising SystemExit, allowing IDLE to honor quit() and exit(). M Lib/site.py M Lib/idlelib/PyShell.py M Lib/idlelib/CREDITS.txt M Lib/idlelib/NEWS.txt M Misc/NEWS git-svn-id: http://svn.python.org/projects/python/trunk@51306 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 0f2fbc1 commit 08107c0

5 files changed

Lines changed: 24 additions & 11 deletions

File tree

Lib/idlelib/CREDITS.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Noam Raphael (Code Context, Call Tips, many other patches), and Chui Tey (RPC
2424
integration, debugger integration and persistent breakpoints).
2525

2626
Scott David Daniels, Tal Einat, Hernan Foffani, Christos Georgiou,
27-
Martin v. L�wis, Jason Orendorff, Josh Robb, Nigel Rowe, Bruce Sherwood,
28-
and Jeff Shute have submitted useful patches. Thanks, guys!
27+
Jim Jewett, Martin v. L�wis, Jason Orendorff, Josh Robb, Nigel Rowe,
28+
Bruce Sherwood, and Jeff Shute have submitted useful patches. Thanks, guys!
2929

3030
For additional details refer to NEWS.txt and Changelog.
3131

Lib/idlelib/NEWS.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ What's New in IDLE 1.2c1?
33

44
*Release date: 17-AUG-2006*
55

6-
- The 'with' statement is now a Code Context block opener
6+
- IDLE honors new quit() and exit() commands from site.py Quitter() object.
7+
Patch 1540892, Jim Jewett
8+
9+
- The 'with' statement is now a Code Context block opener.
10+
Patch 1540851, Jim Jewett
711

812
- Retrieval of previous shell command was not always preserving indentation
913
(since 1.2a1) Patch 1528468 Tal Einat.

Lib/idlelib/PyShell.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,6 @@ def transfer_path(self):
478478
import sys as _sys
479479
_sys.path = %r
480480
del _sys
481-
_msg = 'Use File/Exit or your end-of-file key to quit IDLE'
482-
__builtins__.quit = __builtins__.exit = _msg
483-
del _msg
484481
\n""" % (sys.path,))
485482

486483
active_seq = None
@@ -514,7 +511,10 @@ def poll_subprocess(self):
514511
print >>sys.__stderr__, errmsg, what
515512
print >>console, errmsg, what
516513
# we received a response to the currently active seq number:
517-
self.tkconsole.endexecuting()
514+
try:
515+
self.tkconsole.endexecuting()
516+
except AttributeError: # shell may have closed
517+
pass
518518
# Reschedule myself
519519
if not self.tkconsole.closing:
520520
self.tkconsole.text.after(self.tkconsole.pollinterval,
@@ -730,7 +730,10 @@ def runcode(self, code):
730730
self.tkconsole.endexecuting()
731731
finally:
732732
if not use_subprocess:
733-
self.tkconsole.endexecuting()
733+
try:
734+
self.tkconsole.endexecuting()
735+
except AttributeError: # shell may have closed
736+
pass
734737

735738
def write(self, s):
736739
"Override base class method"
@@ -804,9 +807,6 @@ def __init__(self, flist=None):
804807
#
805808
OutputWindow.__init__(self, flist, None, None)
806809
#
807-
import __builtin__
808-
__builtin__.quit = __builtin__.exit = "To exit, type Ctrl-D."
809-
#
810810
## self.config(usetabs=1, indentwidth=8, context_use_ps1=1)
811811
self.usetabs = True
812812
# indentwidth must be 8 when using tabs. See note in EditorWindow:

Lib/site.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ def __init__(self, name):
242242
def __repr__(self):
243243
return 'Use %s() or %s to exit' % (self.name, eof)
244244
def __call__(self, code=None):
245+
# Shells like IDLE catch the SystemExit, but listen when their
246+
# stdin wrapper is closed.
247+
try:
248+
sys.stdin.close()
249+
except:
250+
pass
245251
raise SystemExit(code)
246252
__builtin__.quit = Quitter('quit')
247253
__builtin__.exit = Quitter('exit')

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ Core and builtins
6464
Library
6565
-------
6666

67+
- Patch #1540892: site.py Quitter() class attempts to close sys.stdin
68+
before raising SystemExit, allowing IDLE to honor quit() and exit().
69+
6770
- Bug #1224621: make tabnanny recognize IndentationErrors raised by tokenize.
6871

6972
- Patch #1536071: trace.py should now find the full module name of a

0 commit comments

Comments
 (0)