diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-09-08 20:44:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-08 20:44:20 (GMT) |
commit | 3b36642924a51e6bceb7033916c3049764817166 (patch) | |
tree | 002c923f58766dfd9efbe14fc2ba839af4b59325 | |
parent | eb6ab73f93c8b883a8d75a83560e2b4c59170d95 (diff) | |
download | cpython-3b36642924a51e6bceb7033916c3049764817166.zip cpython-3b36642924a51e6bceb7033916c3049764817166.tar.gz cpython-3b36642924a51e6bceb7033916c3049764817166.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.
(cherry picked from commit 0afada163c7ef25c3a9d46ed445481fb69f2ecaf)
Co-authored-by: Julien Malard <julien.malard@mail.mcgill.ca>
-rw-r--r-- | Lib/distutils/log.py | 5 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2018-09-07-10-57-00.bpo-34421.AKJISD.rst | 1 |
2 files changed, 5 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): diff --git a/Misc/NEWS.d/next/Library/2018-09-07-10-57-00.bpo-34421.AKJISD.rst b/Misc/NEWS.d/next/Library/2018-09-07-10-57-00.bpo-34421.AKJISD.rst new file mode 100644 index 0000000..cc1db08 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-09-07-10-57-00.bpo-34421.AKJISD.rst @@ -0,0 +1 @@ +Fix distutils logging for non-ASCII strings. This caused installation issues on Windows. |