py3: flush stdout
authorGregory Szorc <gregory.szorc@gmail.com>
Fri, 12 Oct 2018 19:17:22 +0200
changeset 40200 9cc411952ab9
parent 40199 b594db74dc13
child 40201 7df42042636d
py3: flush stdout This avoids buffering due to mixed print() and sys.stdout.write() by profiling code. And with this, test-profile.t passes on Python 3 \o/. Honestly, I'd be shocked if there weren't more Python 3 encoding issues lingering in the profiling code. That code isn't super high quality and doesn't seem to have thorough test coverage. Differential Revision: https://phab.mercurial-scm.org/D5018
tests/test-profile.t
--- a/tests/test-profile.t	Fri Oct 12 19:07:12 2018 +0200
+++ b/tests/test-profile.t	Fri Oct 12 19:17:22 2018 +0200
@@ -117,11 +117,14 @@
   $ cat > fooprof.py <<EOF
   > from __future__ import absolute_import
   > import contextlib
+  > import sys
   > @contextlib.contextmanager
   > def profile(ui, fp):
   >     print('fooprof: start profile')
+  >     sys.stdout.flush()
   >     yield
   >     print('fooprof: end profile')
+  >     sys.stdout.flush()
   > def extsetup(ui):
   >     ui.write(b'fooprof: loaded\n')
   > EOF