[PATCH 5 of 6] py3: flush std streams before/after running user code in heredoctest.py
Yuya Nishihara
yuya at tcha.org
Tue Oct 16 07:26:44 UTC 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1539667110 -7200
# Tue Oct 16 07:18:30 2018 +0200
# Node ID 8190570be13dc584dfab6b8470546c298d6900b6
# Parent a202f1b4611205a08a6730db63dfead59b69f42b
py3: flush std streams before/after running user code in heredoctest.py
Otherwise, things written to stdout.buffer would be interleaved.
diff --git a/tests/heredoctest.py b/tests/heredoctest.py
--- a/tests/heredoctest.py
+++ b/tests/heredoctest.py
@@ -2,6 +2,10 @@ from __future__ import absolute_import,
import sys
+def flush():
+ sys.stdout.flush()
+ sys.stderr.flush()
+
globalvars = {}
lines = sys.stdin.readlines()
while lines:
@@ -15,6 +19,9 @@ while lines:
snippet += l[4:]
c = compile(snippet, '<heredoc>', 'single')
try:
+ flush()
exec(c, globalvars)
+ flush()
except Exception as inst:
+ flush()
print(repr(inst))
More information about the Mercurial-devel
mailing list