Mercurial > public > mercurial-scm > hg
comparison mercurial/windows.py @ 14969:a3f97038c1c2
windows: use getattr instead of hasattr
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 25 Jul 2011 16:04:44 -0500 |
parents | 2aa3e07b2f07 |
children | dbf91976f900 |
comparison
equal
deleted
inserted
replaced
14968:b7dbe957585c | 14969:a3f97038c1c2 |
---|---|
97 return False | 97 return False |
98 | 98 |
99 def setbinary(fd): | 99 def setbinary(fd): |
100 # When run without console, pipes may expose invalid | 100 # When run without console, pipes may expose invalid |
101 # fileno(), usually set to -1. | 101 # fileno(), usually set to -1. |
102 if hasattr(fd, 'fileno') and fd.fileno() >= 0: | 102 fno = getattr(fd, 'fileno', None) |
103 msvcrt.setmode(fd.fileno(), os.O_BINARY) | 103 if fno is not None and fno() >= 0: |
104 msvcrt.setmode(fno(), os.O_BINARY) | |
104 | 105 |
105 def pconvert(path): | 106 def pconvert(path): |
106 return '/'.join(path.split(os.sep)) | 107 return '/'.join(path.split(os.sep)) |
107 | 108 |
108 def localpath(path): | 109 def localpath(path): |