aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-10-26 22:26:31 +0000
committerZac Medico <zmedico@gentoo.org>2009-10-26 22:26:31 +0000
commitad9e5fe8a557b1cb0b54aeb5268eb209abfaf0c8 (patch)
tree65d16296bca818bddadb9583d709059449ce0beb /pym/portage/elog
parentRevert the workaround for bug #288863. This will require a dependency on (diff)
downloadportage-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.py11
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)