summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/log.py
diff options
context:
space:
mode:
authorJulien Malard <julien.malard@mail.mcgill.ca>2018-09-08 20:31:26 (GMT)
committerÉric Araujo <merwok@netwok.org>2018-09-08 20:31:26 (GMT)
commit0afada163c7ef25c3a9d46ed445481fb69f2ecaf (patch)
tree71508b730ec4886480cc5c7816a84eea65b4aed3 /Lib/distutils/log.py
parentd700f97b627989d41cd4629dc02969f9a6b56d2f (diff)
downloadcpython-0afada163c7ef25c3a9d46ed445481fb69f2ecaf.zip
cpython-0afada163c7ef25c3a9d46ed445481fb69f2ecaf.tar.gz
cpython-0afada163c7ef25c3a9d46ed445481fb69f2ecaf.tar.bz2
bpo-34421 avoid unicode error in distutils logging (GH-8799)
This caused installation errors in some cases on Windows. Patch by Julien Malard.
Diffstat (limited to 'Lib/distutils/log.py')
-rw-r--r--Lib/distutils/log.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/distutils/log.py b/Lib/distutils/log.py
index b301a83..3a6602b 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):