[PATCH 2 of 2] py3: flush ui after each message in interactive patch filtering

Denis Laxalde denis at laxalde.org
Thu Oct 10 09:19:37 EDT 2019

Yuya Nishihara a écrit :
> I suspect that "sys.stdout.buffer" isn't line-buffered on Python 3 even
> though "sys.stdout" is documented as such. If that's true, we'll need another
> hack to make our stdout do the right thing.
> https://docs.python.org/3/library/sys.html#sys.stdout

As far as I can tell, "sys.stdout.buffer" is line-buffered on python3. It
seems to me that the problem is that we're not actually using this but
procutil.stdout as ui._fout; and procutil happens to replace stdout
(initially "sys.stdout.buffer") by "os.fdopen(stdout.fileno(), r'wb',
1)". But apparently, the buffering=1 argument is not usable for binary
mode, according to:


I would then suggest to not replace stdout in procutil when using
python3 (and keep sys.stdout.buffer). Would that be correct?

(There are more such issues, e.g. in "hg email", so it's indeed worth
a correct fix.)

More information about the Mercurial-devel mailing list