From: Zac Medico Date: Sun, 20 Sep 2009 20:00:57 +0000 (-0000) Subject: Use _unicode_encode() to ensure that only unicode strings are passed into X-Git-Tag: v2.2_rc42~101 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8eab4a8bca97d338fc141278b46d89d3e5a54360;p=portage.git Use _unicode_encode() to ensure that only unicode strings are passed into io.StringIO text streams. svn path=/main/trunk/; revision=14301 --- 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))