# HG changeset patch # User Denis Laxalde # Date 2019-10-10 14:00:02 # Node ID 227ba1afcb657e936502303a490a6805c273c051 # Parent c32531444cdc6fa75dd2aca262ff9e0df038c188 py3: keep stdout as defined by pycompat in procutil According to https://docs.python.org/3/library/functions.html#open, it's not possible to use 1 as buffering argument value in binary mode. This is probably why line buffering does not work well in python3. On the other hand, sys.stdout.buffer appears to be line-buffered already on python3. So by not replacing it, there should be no behavior change. This fixes buffering issue in "hg email" (confirmation prompt shown before information to be confirmed). diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -53,7 +53,9 @@ if isatty(stdout): if pycompat.iswindows: # Windows doesn't support line buffering stdout = os.fdopen(stdout.fileno(), r'wb', 0) - else: + elif not pycompat.ispy3: + # on Python 3, stdout (sys.stdout.buffer) is already line buffered and + # buffering=1 is not handled in binary mode stdout = os.fdopen(stdout.fileno(), r'wb', 1) if pycompat.iswindows: