comparison mercurial/utils/procutil.py @ 43165:227ba1afcb65

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).
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 10 Oct 2019 16:00:02 +0200
parents 4aa72cdf616f
children 54f4d094bab1 15a6c6783060
comparison
equal deleted inserted replaced
43164:c32531444cdc 43165:227ba1afcb65
51 # buffering (or unbuffered, on Windows) 51 # buffering (or unbuffered, on Windows)
52 if isatty(stdout): 52 if isatty(stdout):
53 if pycompat.iswindows: 53 if pycompat.iswindows:
54 # Windows doesn't support line buffering 54 # Windows doesn't support line buffering
55 stdout = os.fdopen(stdout.fileno(), r'wb', 0) 55 stdout = os.fdopen(stdout.fileno(), r'wb', 0)
56 else: 56 elif not pycompat.ispy3:
57 # on Python 3, stdout (sys.stdout.buffer) is already line buffered and
58 # buffering=1 is not handled in binary mode
57 stdout = os.fdopen(stdout.fileno(), r'wb', 1) 59 stdout = os.fdopen(stdout.fileno(), r'wb', 1)
58 60
59 if pycompat.iswindows: 61 if pycompat.iswindows:
60 from .. import windows as platform 62 from .. import windows as platform
61 63