Mercurial > hg
comparison mercurial/ui.py @ 43377:aaa046919043 stable
ui: flush before prompting for input with readline
I was using `hg absorb` with Python 3 and noticed that the
prompt was appearing without any output about what would be
done. After I answered the prompt, the output was printed
to stdout.
This appears to be a buffering difference between Python 2
and Python 3.
To work around it, this commit adds an explicit flush() before
calling the raw input function when readline is used.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 02 Nov 2019 15:33:39 -0700 |
parents | 82879e06c926 |
children | 9f70512ae2cf |
comparison
equal
deleted
inserted
replaced
43376:b27cf9f52194 | 43377:aaa046919043 |
---|---|
1562 | 1562 |
1563 # prompt ' ' must exist; otherwise readline may delete entire line | 1563 # prompt ' ' must exist; otherwise readline may delete entire line |
1564 # - http://bugs.python.org/issue12833 | 1564 # - http://bugs.python.org/issue12833 |
1565 with self.timeblockedsection(b'stdio'): | 1565 with self.timeblockedsection(b'stdio'): |
1566 if usereadline: | 1566 if usereadline: |
1567 self.flush() | |
1567 prompt = encoding.strfromlocal(prompt) | 1568 prompt = encoding.strfromlocal(prompt) |
1568 line = encoding.strtolocal(pycompat.rawinput(prompt)) | 1569 line = encoding.strtolocal(pycompat.rawinput(prompt)) |
1569 # When stdin is in binary mode on Windows, it can cause | 1570 # When stdin is in binary mode on Windows, it can cause |
1570 # raw_input() to emit an extra trailing carriage return | 1571 # raw_input() to emit an extra trailing carriage return |
1571 if pycompat.oslinesep == b'\r\n' and line.endswith(b'\r'): | 1572 if pycompat.oslinesep == b'\r\n' and line.endswith(b'\r'): |