]> granicus.if.org Git - python/commitdiff
Don't close sys.stdin with quit() if sys.stdin wraps fd 0. Otherwise it will raise...
authorChristian Heimes <christian@cheimes.de>
Mon, 31 Dec 2007 03:07:24 +0000 (03:07 +0000)
committerChristian Heimes <christian@cheimes.de>
Mon, 31 Dec 2007 03:07:24 +0000 (03:07 +0000)
Lib/site.py

index 4d64d20ccf7457aeff7a8f5b3dc8876129cc1482..3ba42121f6b03fea82870a65bd46556d91caa6a0 100644 (file)
@@ -247,7 +247,12 @@ def setquit():
             # Shells like IDLE catch the SystemExit, but listen when their
             # stdin wrapper is closed.
             try:
-                sys.stdin.close()
+                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()
             except:
                 pass
             raise SystemExit(code)