Mercurial > hg-stable
changeset 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 | c26335fa4225 |
children | ed58ecd59030 |
files | mercurial/windows.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/windows.py Fri Jul 17 08:21:31 2020 +0200 +++ b/mercurial/windows.py Fri Jul 17 14:58:22 2020 +0200 @@ -186,6 +186,14 @@ listdir = osutil.listdir +# copied from .utils.procutil, remove after Python 2 support was dropped +def _isatty(fp): + try: + return fp.isatty() + except AttributeError: + return False + + class winstdout(object): '''Some files on Windows misbehave. @@ -197,7 +205,7 @@ def __init__(self, fp): self.fp = fp - self.throttle = not pycompat.ispy3 and fp.isatty() + self.throttle = not pycompat.ispy3 and _isatty(fp) def __getattr__(self, key): return getattr(self.fp, key)