Skip to content

Commit 78ce8d3

Browse files
MoLowRafaelGSS
authored andcommitted
tools: allow test tap output to include unicode characters
PR-URL: #47175 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Christian Clauss <cclauss@me.com>
1 parent 4530582 commit 78ce8d3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/test.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import multiprocessing
4545
import errno
4646
import copy
47+
import io
4748

4849

4950
if sys.version_info >= (3, 5):
@@ -1595,7 +1596,13 @@ def Main():
15951596
parser.print_help()
15961597
return 1
15971598

1598-
ch = logging.StreamHandler(sys.stdout)
1599+
stream = sys.stdout
1600+
try:
1601+
sys.stdout.reconfigure(encoding='utf8')
1602+
except AttributeError:
1603+
# Python < 3.7 does not have reconfigure
1604+
stream = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
1605+
ch = logging.StreamHandler(stream)
15991606
logger.addHandler(ch)
16001607
logger.setLevel(logging.INFO)
16011608
if options.logfile:

0 commit comments

Comments
 (0)