summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/output.py5
-rw-r--r--pym/repoman/utilities.py19
2 files changed, 17 insertions, 7 deletions
diff --git a/pym/portage/output.py b/pym/portage/output.py
index a85647c4d..c21dc07ba 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -355,6 +355,11 @@ class ConsoleStyleFile(object):
self._styles = styles
def write(self, s):
+ # In python-2.6, DumbWriter.send_line_break() can write
+ # non-unicode '\n' which fails with TypeError if self._file
+ # is a text stream such as io.StringIO. Therefore, make sure
+ # input is converted to unicode when necessary.
+ s = _unicode_decode(s)
global havecolor
if havecolor and self._styles:
for style in self._styles:
diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py
index fcabd599d..3d8d43aed 100644
--- a/pym/repoman/utilities.py
+++ b/pym/repoman/utilities.py
@@ -33,6 +33,7 @@ from xml.dom import NotFoundErr
from xml.parsers.expat import ExpatError
from portage import os
from portage import _encodings
+from portage import _unicode_decode
from portage import _unicode_encode
from portage import output
from portage.output import red, green
@@ -221,12 +222,12 @@ def format_qa_output(formatter, stats, fails, dofull, dofail, options, qawarning
# we only want key value pairs where value > 0
for category, number in \
itertools.ifilter(lambda myitem: myitem[1] > 0, stats.iteritems()):
- formatter.add_literal_data(" " + category.ljust(30))
+ formatter.add_literal_data(_unicode_decode(" " + category.ljust(30)))
if category in qawarnings:
formatter.push_style("WARN")
else:
formatter.push_style("BAD")
- formatter.add_literal_data(str(number))
+ formatter.add_literal_data(_unicode_decode(str(number)))
formatter.pop_style()
formatter.add_line_break()
if not dofull:
@@ -237,7 +238,7 @@ def format_qa_output(formatter, stats, fails, dofull, dofail, options, qawarning
if not full and len(fails_list) > 12:
fails_list = fails_list[:12]
for failure in fails_list:
- formatter.add_literal_data(" " + failure)
+ formatter.add_literal_data(_unicode_decode(" " + failure))
formatter.add_line_break()
@@ -276,13 +277,17 @@ def get_commit_message_with_editor(editor, message=None):
from tempfile import mkstemp
fd, filename = mkstemp()
try:
- os.write(fd, "\n# Please enter the commit message " + \
+ os.write(fd, _unicode_encode(
+ "\n# Please enter the commit message " + \
"for your changes.\n# (Comment lines starting " + \
- "with '#' will not be included)\n")
+ "with '#' will not be included)\n",
+ encoding=_encodings['content'], errors='backslashreplace'))
if message:
- os.write(fd, "#\n")
+ os.write(fd, _unicode_encode("#\n",
+ encoding=_encodings['content'], errors='backslashreplace'))
for line in message:
- os.write(fd, "#" + line)
+ os.write(fd, _unicode_encode("#" + line,
+ encoding=_encodings['content'], errors='backslashreplace'))
os.close(fd)
retval = os.system(editor + " '%s'" % filename)
if not (os.WIFEXITED(retval) and os.WEXITSTATUS(retval) == os.EX_OK):