Mercurial > hg-stable
comparison mercurial/windows.py @ 45157:74b486226480
windows: handle file-like objects without isatty() method
Copying the function is not nice, but moving around stuff to avoid the
circular import didn’t seem to be worth the effort.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Fri, 17 Jul 2020 14:58:22 +0200 |
parents | a37f290a7124 |
children | ed58ecd59030 |
comparison
equal
deleted
inserted
replaced
45156:c26335fa4225 | 45157:74b486226480 |
---|---|
184 | 184 |
185 # may be wrapped by win32mbcs extension | 185 # may be wrapped by win32mbcs extension |
186 listdir = osutil.listdir | 186 listdir = osutil.listdir |
187 | 187 |
188 | 188 |
189 # copied from .utils.procutil, remove after Python 2 support was dropped | |
190 def _isatty(fp): | |
191 try: | |
192 return fp.isatty() | |
193 except AttributeError: | |
194 return False | |
195 | |
196 | |
189 class winstdout(object): | 197 class winstdout(object): |
190 '''Some files on Windows misbehave. | 198 '''Some files on Windows misbehave. |
191 | 199 |
192 When writing to a broken pipe, EINVAL instead of EPIPE may be raised. | 200 When writing to a broken pipe, EINVAL instead of EPIPE may be raised. |
193 | 201 |
195 error may happen. Python 3 already works around that. | 203 error may happen. Python 3 already works around that. |
196 ''' | 204 ''' |
197 | 205 |
198 def __init__(self, fp): | 206 def __init__(self, fp): |
199 self.fp = fp | 207 self.fp = fp |
200 self.throttle = not pycompat.ispy3 and fp.isatty() | 208 self.throttle = not pycompat.ispy3 and _isatty(fp) |
201 | 209 |
202 def __getattr__(self, key): | 210 def __getattr__(self, key): |
203 return getattr(self.fp, key) | 211 return getattr(self.fp, key) |
204 | 212 |
205 def close(self): | 213 def close(self): |