summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-20 20:00:57 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-20 20:00:57 +0000
commit8eab4a8bca97d338fc141278b46d89d3e5a54360 (patch)
treefea8ac391bda18d8be39eefafef9416f4fab1e53
parentefb3c3c3b578d851539e12ec21da7ea5bf8a6dc2 (diff)
downloadportage-8eab4a8bca97d338fc141278b46d89d3e5a54360.tar.gz
portage-8eab4a8bca97d338fc141278b46d89d3e5a54360.tar.bz2
portage-8eab4a8bca97d338fc141278b46d89d3e5a54360.zip
Use _unicode_encode() to ensure that only unicode strings are passed into
io.StringIO text streams. svn path=/main/trunk/; revision=14301
-rw-r--r--pym/_emerge/JobStatusDisplay.py29
-rw-r--r--pym/portage/output.py7
2 files changed, 22 insertions, 14 deletions
diff --git a/pym/_emerge/JobStatusDisplay.py b/pym/_emerge/JobStatusDisplay.py
index dd72a2971..7cf3607fb 100644
--- a/pym/_emerge/JobStatusDisplay.py
+++ b/pym/_emerge/JobStatusDisplay.py
@@ -10,6 +10,7 @@ from io import StringIO
import portage
from portage import os
from portage import _encodings
+from portage import _unicode_decode
from portage.output import xtermTitle
from _emerge.getloadavg import getloadavg
@@ -222,36 +223,36 @@ class JobStatusDisplay(object):
f = formatter.AbstractFormatter(style_writer)
number_style = "INFORM"
- f.add_literal_data("Jobs: ")
+ f.add_literal_data(_unicode_decode("Jobs: "))
f.push_style(number_style)
- f.add_literal_data(curval_str)
+ f.add_literal_data(_unicode_decode(curval_str))
f.pop_style()
- f.add_literal_data(" of ")
+ f.add_literal_data(_unicode_decode(" of "))
f.push_style(number_style)
- f.add_literal_data(maxval_str)
+ f.add_literal_data(_unicode_decode(maxval_str))
f.pop_style()
- f.add_literal_data(" complete")
+ f.add_literal_data(_unicode_decode(" complete"))
if self.running:
- f.add_literal_data(", ")
+ f.add_literal_data(_unicode_decode(", "))
f.push_style(number_style)
- f.add_literal_data(running_str)
+ f.add_literal_data(_unicode_decode(running_str))
f.pop_style()
- f.add_literal_data(" running")
+ f.add_literal_data(_unicode_decode(" running"))
if self.failed:
- f.add_literal_data(", ")
+ f.add_literal_data(_unicode_decode(", "))
f.push_style(number_style)
- f.add_literal_data(failed_str)
+ f.add_literal_data(_unicode_decode(failed_str))
f.pop_style()
- f.add_literal_data(" failed")
+ f.add_literal_data(_unicode_decode(" failed"))
padding = self._jobs_column_width - len(plain_output.getvalue())
if padding > 0:
- f.add_literal_data(padding * " ")
+ f.add_literal_data(padding * _unicode_decode(" "))
- f.add_literal_data("Load avg: ")
- f.add_literal_data(load_avg_str)
+ f.add_literal_data(_unicode_decode("Load avg: "))
+ f.add_literal_data(_unicode_decode(load_avg_str))
# Truncate to fit width, to avoid making the terminal scroll if the
# line overflows (happens when the load average is large).
diff --git a/pym/portage/output.py b/pym/portage/output.py
index 5170d70aa..a85647c4d 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -22,6 +22,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
from portage import os
from portage import _encodings
from portage import _unicode_encode
+from portage import _unicode_decode
from portage.const import COLOR_MAP_FILE
from portage.exception import CommandNotFound, FileNotFound, \
ParseError, PermissionDenied, PortageException
@@ -743,6 +744,12 @@ def _init(config_root='/'):
codes = object.__getattribute__(codes, '_attr')
_styles = object.__getattribute__(_styles, '_attr')
+ for k, v in codes.iteritems():
+ codes[k] = _unicode_decode(v)
+
+ for k, v in _styles.iteritems():
+ _styles[k] = _unicode_decode(v)
+
try:
_parse_color_map(config_root=config_root,
onerror=lambda e: writemsg("%s\n" % str(e), noiselevel=-1))