So Unicode log messages handled by StreamHandler will be properly
encoded. In Python 2.7.3 (and probably other 2.x versions),
StreamHandler.emit() falls back on UTF-8 if stream.encoding is None.
With this change, it will use the configured output encoding instead
of guessing.
'system', key,
CONFIG.get('system', key, raw=True) or default_encoding)
- # HACK: convert sys.stdout to Unicode (not needed in Python 3)
+ # HACK: convert sys.std{out,err} to Unicode (not needed in Python 3)
output_encoding = CONFIG.get('system', 'output-encoding')
_sys.stdout = _codecs.getwriter(output_encoding)(_sys.stdout)
+ _sys.stderr = _codecs.getwriter(output_encoding)(_sys.stderr)
# HACK: convert sys.argv to Unicode (not needed in Python 3)
argv_encoding = CONFIG.get('system', 'argv-encoding')