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
This commit is contained in:
Kurt B. Kaiser 2006-08-16 05:01:42 +00:00
parent 798ed8f076
commit d112bc7958
5 changed files with 24 additions and 11 deletions

View file

@ -242,6 +242,12 @@ def setquit():
def __repr__(self):
return 'Use %s() or %s to exit' % (self.name, eof)
def __call__(self, code=None):
# Shells like IDLE catch the SystemExit, but listen when their
# stdin wrapper is closed.
try:
sys.stdin.close()
except:
pass
raise SystemExit(code)
__builtin__.quit = Quitter('quit')
__builtin__.exit = Quitter('exit')