changeset 40318:55fd0fefbec4

py3: flush std streams before/after running user code in heredoctest.py Otherwise, things written to stdout.buffer would be interleaved.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 16 Oct 2018 07:18:30 +0200
parents 6958eb9bdcd6
children eb131464c805
files tests/heredoctest.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/heredoctest.py	Tue Oct 16 08:06:17 2018 +0200
+++ b/tests/heredoctest.py	Tue Oct 16 07:18:30 2018 +0200
@@ -2,6 +2,10 @@
 
 import sys
 
+def flush():
+    sys.stdout.flush()
+    sys.stderr.flush()
+
 globalvars = {}
 lines = sys.stdin.readlines()
 while lines:
@@ -15,6 +19,9 @@
             snippet += l[4:]
         c = compile(snippet, '<heredoc>', 'single')
         try:
+            flush()
             exec(c, globalvars)
+            flush()
         except Exception as inst:
+            flush()
             print(repr(inst))