windows: use getattr instead of hasattr
authorAugie Fackler <durin42@gmail.com>
Mon, 25 Jul 2011 16:04:44 -0500
changeset 14969 a3f97038c1c2
parent 14968 b7dbe957585c
child 14970 592e45b7d43e
windows: use getattr instead of hasattr
mercurial/windows.py
--- a/mercurial/windows.py	Mon Jul 25 16:04:40 2011 -0500
+++ b/mercurial/windows.py	Mon Jul 25 16:04:44 2011 -0500
@@ -99,8 +99,9 @@
 def setbinary(fd):
     # 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)
+    fno = getattr(fd, 'fileno', None)
+    if fno is not None and fno() >= 0:
+        msvcrt.setmode(fno(), os.O_BINARY)
 
 def pconvert(path):
     return '/'.join(path.split(os.sep))