From 78ce8d3469174a81c19d02cf9dc29c5888a61d63 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 21 Mar 2023 19:27:53 +0200 Subject: [PATCH] tools: allow test tap output to include unicode characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/47175 Reviewed-By: Richard Lau Reviewed-By: Michaƫl Zasso Reviewed-By: Christian Clauss --- tools/test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index cdcd6c148278e2..44f21ec126b25d 100755 --- a/tools/test.py +++ b/tools/test.py @@ -44,6 +44,7 @@ import multiprocessing import errno import copy +import io if sys.version_info >= (3, 5): @@ -1595,7 +1596,13 @@ def Main(): parser.print_help() return 1 - ch = logging.StreamHandler(sys.stdout) + stream = sys.stdout + try: + sys.stdout.reconfigure(encoding='utf8') + except AttributeError: + # Python < 3.7 does not have reconfigure + stream = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') + ch = logging.StreamHandler(stream) logger.addHandler(ch) logger.setLevel(logging.INFO) if options.logfile: