Commit 862543aa authored by Christian Heimes's avatar Christian Heimes

Don't close sys.stdin with quit() if sys.stdin wraps fd 0. Otherwise it will...

Don't close sys.stdin with quit() if sys.stdin wraps fd 0. Otherwise it will raise a warning: Lib/io.py:1221: RuntimeWarning: Trying to close unclosable fd
parent c90584ec
...@@ -247,6 +247,11 @@ def setquit(): ...@@ -247,6 +247,11 @@ def setquit():
# Shells like IDLE catch the SystemExit, but listen when their # Shells like IDLE catch the SystemExit, but listen when their
# stdin wrapper is closed. # stdin wrapper is closed.
try: try:
fd = -1
if hasattr(sys.stdin, "fileno"):
fd = sys.stdin.fileno()
if fd != 0:
# Don't close stdin if it wraps fd 0
sys.stdin.close() sys.stdin.close()
except: except:
pass pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment