util.termwidth: a file-like object may legitimately lack a fileno() method
authorBryan O'Sullivan <bos@serpentine.com>
Mon, 11 May 2009 11:53:27 -0700
changeset 8347 a3826fff1e87
parent 8346 b579823cc546
child 8348 c9ab8f448a9e
util.termwidth: a file-like object may legitimately lack a fileno() method Spotted in the wild when running a hook while pushing over HTTPS.
mercurial/util.py
--- a/mercurial/util.py	Mon May 11 14:19:49 2009 +0200
+++ b/mercurial/util.py	Mon May 11 11:53:27 2009 -0700
@@ -1438,7 +1438,10 @@
         import termios, array, fcntl
         for dev in (sys.stdout, sys.stdin):
             try:
-                fd = dev.fileno()
+                try:
+                    fd = dev.fileno()
+                except AttributeError:
+                    continue
                 if not os.isatty(fd):
                     continue
                 arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)