From 0afada163c7ef25c3a9d46ed445481fb69f2ecaf Mon Sep 17 00:00:00 2001 From: Julien Malard Date: Sun, 9 Sep 2018 02:01:26 +0530 Subject: bpo-34421 avoid unicode error in distutils logging (GH-8799) This caused installation errors in some cases on Windows. Patch by Julien Malard. --- Lib/distutils/log.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Lib/distutils/log.py') diff --git a/Lib/distutils/log.py b/Lib/distutils/log.py index b301a8338c..3a6602bc8b 100644 --- a/Lib/distutils/log.py +++ b/Lib/distutils/log.py @@ -31,7 +31,10 @@ class Log: # emulate backslashreplace error handler encoding = stream.encoding msg = msg.encode(encoding, "backslashreplace").decode(encoding) - stream.write('%s\n' % msg) + try: + stream.write('%s\n' % msg) + except UnicodeEncodeError: + stream.write('%s\n' % msg.encode('unicode-escape').decode('ascii')) stream.flush() def log(self, level, msg, *args): -- cgit v1.2.1