# HG changeset patch # User Manuel Jacob # Date 2020-07-17 12:58:22 # Node ID 74b486226480fedb1d78eb44566c8733bb6c38c4 # Parent c26335fa4225eaf19e444724a97746d47cc4fea2 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. diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -186,6 +186,14 @@ def posixfile(name, mode=b'r', buffering 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 @@ class winstdout(object): 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)