# HG changeset patch # User Manuel Jacob # Date 1593657438 -7200 # Node ID 2bfbd7d2c204734616f15237894feb4b9eaa3c1f # Parent c7d109c400a417856d4c949be6baa4236cfd2731 procutil: define LineBufferedWrapper on all Python versions There’s nothing Python 3-only about LineBufferedWrapper. In the future, we may want to use it on Windows, to work around missing line-buffering support. diff -r c7d109c400a4 -r 2bfbd7d2c204 mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py Sat Jul 04 10:47:04 2020 +0200 +++ b/mercurial/utils/procutil.py Thu Jul 02 04:37:18 2020 +0200 @@ -49,23 +49,22 @@ return False -if pycompat.ispy3: +class LineBufferedWrapper(object): + def __init__(self, orig): + self.orig = orig - class LineBufferedWrapper(object): - def __init__(self, orig): - self.orig = orig - - def __getattr__(self, attr): - return getattr(self.orig, attr) + def __getattr__(self, attr): + return getattr(self.orig, attr) - def write(self, s): - orig = self.orig - res = orig.write(s) - if s.endswith(b'\n'): - orig.flush() - return res + def write(self, s): + orig = self.orig + res = orig.write(s) + if s.endswith(b'\n'): + orig.flush() + return res - io.BufferedIOBase.register(LineBufferedWrapper) + +io.BufferedIOBase.register(LineBufferedWrapper) # glibc determines buffering on first write to stdout - if we replace a TTY