diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-10-27 22:55:54 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-10-27 22:55:54 +0000 |
commit | b3670f856ad211e43d5d1c8434877ad1a35eab4b (patch) | |
tree | bf1ea5293215b31e25ba6c0426bf94a13c1fd666 /pym/_emerge | |
parent | 67b314d17bbccbd591919c524aeb562b43338a48 (diff) | |
download | portage-b3670f856ad211e43d5d1c8434877ad1a35eab4b.tar.gz portage-b3670f856ad211e43d5d1c8434877ad1a35eab4b.tar.bz2 portage-b3670f856ad211e43d5d1c8434877ad1a35eab4b.zip |
Bug #290625 - Manually encode output to stdout in python3, in order to avoid
potential UnicodeEncodeError exceptions. (trunk r14734)
svn path=/main/branches/2.1.7/; revision=14741
Diffstat (limited to 'pym/_emerge')
-rw-r--r-- | pym/_emerge/JobStatusDisplay.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pym/_emerge/JobStatusDisplay.py b/pym/_emerge/JobStatusDisplay.py index 1c80c5ffa..bcc682b23 100644 --- a/pym/_emerge/JobStatusDisplay.py +++ b/pym/_emerge/JobStatusDisplay.py @@ -17,6 +17,7 @@ import portage from portage import os from portage import _encodings from portage import _unicode_decode +from portage import _unicode_encode from portage.output import xtermTitle from _emerge.getloadavg import getloadavg @@ -75,11 +76,14 @@ class JobStatusDisplay(object): return sys.stdout def _write(self, s): - if sys.hexversion < 0x3000000 and isinstance(s, unicode): - # avoid potential UnicodeEncodeError - s = s.encode(_encodings['stdio'], 'backslashreplace') - self.out.write(s) - self.out.flush() + # avoid potential UnicodeEncodeError + s = _unicode_encode(s, + encoding=_encodings['stdio'], errors='backslashreplace') + out = self.out + if sys.hexversion >= 0x3000000: + out = out.buffer + out.write(s) + out.flush() def _init_term(self): """ |