bpo-34421 avoid unicode error in distutils logging (GH-8799) · python/cpython@77b92b1 (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit 77b92b1
and
authored
This caused installation errors in some cases on Windows. Patch by Julien Malard. (cherry picked from commit 0afada1) Co-authored-by: Julien Malard julien.malard@mail.mcgill.ca
File tree
2 files changed
lines changed
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -31,7 +31,10 @@ def _log(self, level, msg, args): | ||
31 | 31 | # emulate backslashreplace error handler |
32 | 32 | encoding = stream.encoding |
33 | 33 | 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')) | |
35 | 38 | stream.flush() |
36 | 39 | |
37 | 40 | def log(self, level, msg, *args): |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 | +Fix distutils logging for non-ASCII strings. This caused installation issues on Windows. |