# HG changeset patch # User Patrick Mezard # Date 2008-03-21 20:56:55 # Node ID ed9b07a97587eacbf3a6477776391c2543eba2bc # Parent 0750f11152febd2ff4ca7439957b77111d99cc63 util: check fileno() validity in win32 set_binary() diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1000,7 +1000,9 @@ if os.name == 'nt': 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):