From: Victor Stinner Date: Wed, 19 May 2010 17:00:07 +0000 (+0000) Subject: Issue #8663: distutils.log emulates backslashreplace error handler. Fix X-Git-Tag: v3.2a1~746 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ca03c1f7f476445019e67d6b44189b85259ef17;p=python Issue #8663: distutils.log emulates backslashreplace error handler. Fix compilation in a non-ASCII directory if stdout encoding is ASCII (eg. if stdout is not a TTY). --- diff --git a/Lib/distutils/log.py b/Lib/distutils/log.py index 758857081c..b301a8338c 100644 --- a/Lib/distutils/log.py +++ b/Lib/distutils/log.py @@ -27,6 +27,10 @@ class Log: stream = sys.stderr else: stream = sys.stdout + if stream.errors == 'strict': + # emulate backslashreplace error handler + encoding = stream.encoding + msg = msg.encode(encoding, "backslashreplace").decode(encoding) stream.write('%s\n' % msg) stream.flush() diff --git a/Misc/NEWS b/Misc/NEWS index ceda9b7392..3e582cdbc5 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -370,6 +370,10 @@ C-API Library ------- +- Issue #8663: distutils.log emulates backslashreplace error handler. Fix + compilation in a non-ASCII directory if stdout encoding is ASCII (eg. if + stdout is not a TTY). + - Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value. subprocess.Popen() and os._execvpe() support bytes program name. Add os.supports_bytes_environ flag: True if the native OS type of the environment