diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-10-26 22:26:31 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-10-26 22:26:31 +0000 |
commit | ad9e5fe8a557b1cb0b54aeb5268eb209abfaf0c8 (patch) | |
tree | 65d16296bca818bddadb9583d709059449ce0beb /pym/portage/elog | |
parent | 403624a789efd1476a1a00a5c9808a5c1e8fe830 (diff) | |
download | portage-ad9e5fe8a557b1cb0b54aeb5268eb209abfaf0c8.tar.gz portage-ad9e5fe8a557b1cb0b54aeb5268eb209abfaf0c8.tar.bz2 portage-ad9e5fe8a557b1cb0b54aeb5268eb209abfaf0c8.zip |
Bug #290625 - Manually encode output to stdout in python3, in order to avoid
potential UnicodeEncodeError exceptions.
svn path=/main/trunk/; revision=14734
Diffstat (limited to 'pym/portage/elog')
-rw-r--r-- | pym/portage/elog/messages.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py index a563ad271..b2a2dc4cf 100644 --- a/pym/portage/elog/messages.py +++ b/pym/portage/elog/messages.py @@ -96,11 +96,12 @@ def _elog_base(level, msg, phase="other", key=None, color=None, out=None): formatted_msg = colorize(color, " * ") + msg + "\n" - if sys.hexversion < 0x3000000 and \ - out in (sys.stdout, sys.stderr) and isinstance(formatted_msg, unicode): - # avoid potential UnicodeEncodeError - formatted_msg = formatted_msg.encode( - _encodings['stdio'], 'backslashreplace') + # avoid potential UnicodeEncodeError + if out in (sys.stdout, sys.stderr): + formatted_msg = _unicode_encode(formatted_msg, + encoding=_encodings['stdio'], errors='backslashreplace') + if sys.hexversion >= 0x3000000: + out = out.buffer out.write(formatted_msg) |