Author: christian.heimes
Date: Mon Dec 31 04:07:24 2007
New Revision: 59614

Modified:
   python/branches/py3k/Lib/site.py
Log:
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

Modified: python/branches/py3k/Lib/site.py
==============================================================================
--- python/branches/py3k/Lib/site.py    (original)
+++ python/branches/py3k/Lib/site.py    Mon Dec 31 04:07:24 2007
@@ -247,7 +247,12 @@
             # 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)
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to