summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-08-22 19:28:35 +0000
committerZac Medico <zmedico@gentoo.org>2009-08-22 19:28:35 +0000
commit0df6293a40d0c021594b8edb613e683c5e18d359 (patch)
treee36ac8264e9bce46f1d11d8a6a7d03481895139a
parentf14d991ee04bfce34bcbb35f032afb463f6ab404 (diff)
downloadportage-0df6293a40d0c021594b8edb613e683c5e18d359.tar.gz
portage-0df6293a40d0c021594b8edb613e683c5e18d359.tar.bz2
portage-0df6293a40d0c021594b8edb613e683c5e18d359.zip
Bug #282269, comment #2 - Avoid potential UnicodeEncodeError when writing
to sys.stderr inside xtermTitle(). svn path=/main/trunk/; revision=14126
-rw-r--r--pym/portage/output.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/pym/portage/output.py b/pym/portage/output.py
index 0e016c5c6..637535b0b 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -252,6 +252,9 @@ def xtermTitle(mystr, raw=False):
mystr = mystr[:_max_xtermTitle_len]
if not raw:
mystr = '\x1b]0;%s\x07' % mystr
+ if sys.hexversion < 0x3000000 and isinstance(mystr, unicode):
+ # avoid potential UnicodeEncodeError
+ mystr = mystr.encode(_encodings['stdio'], 'backslashreplace')
sys.stderr.write(mystr)
sys.stderr.flush()