mercurial/util.py
changeset 6339 ed9b07a97587
parent 6330 4e836769d93c
child 6470 ac0bcd951c2c
child 6835 08d9e0f974d9
--- a/mercurial/util.py	Fri Mar 21 14:52:24 2008 +0100
+++ b/mercurial/util.py	Fri Mar 21 21:56:55 2008 +0100
@@ -1000,7 +1000,9 @@
         pass
 
     def set_binary(fd):
-        if hasattr(fd, 'fileno'):
+        # When run without console, pipes may expose invalid
+        # fileno(), usually set to -1.
+        if hasattr(fd, 'fileno') and fd.fileno() >= 0:
             msvcrt.setmode(fd.fileno(), os.O_BINARY)
 
     def pconvert(path):