Skip to content

Commit 3b36642

Browse files
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 0afada1) Co-authored-by: Julien Malard <[email protected]>
1 parent eb6ab73 commit 3b36642

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/distutils/log.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ def _log(self, level, msg, args):
3131
# emulate backslashreplace error handler
3232
encoding = stream.encoding
3333
msg = msg.encode(encoding, "backslashreplace").decode(encoding)
34-
stream.write('%s\n' % msg)
34+
try:
35+
stream.write('%s\n' % msg)
36+
except UnicodeEncodeError:
37+
stream.write('%s\n' % msg.encode('unicode-escape').decode('ascii'))
3538
stream.flush()
3639

3740
def log(self, level, msg, *args):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix distutils logging for non-ASCII strings. This caused installation issues on Windows.

0 commit comments

Comments
 (0)