summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/RepoDisplay.py12
-rw-r--r--pym/_emerge/depgraph.py10
2 files changed, 17 insertions, 5 deletions
diff --git a/pym/_emerge/RepoDisplay.py b/pym/_emerge/RepoDisplay.py
index f5efd65c8..5a66b5b9c 100644
--- a/pym/_emerge/RepoDisplay.py
+++ b/pym/_emerge/RepoDisplay.py
@@ -1,8 +1,11 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import sys
+
from portage.output import teal
from portage import os
+from portage import _encodings, _unicode_encode
class RepoDisplay(object):
def __init__(self, roots):
@@ -67,3 +70,10 @@ class RepoDisplay(object):
" indicates that the source repository could not be determined\n")
return "".join(output)
+ if sys.hexversion < 0x3000000:
+
+ __unicode__ = __str__
+
+ def __str__(self):
+ return _unicode_encode(self.__unicode__(),
+ encoding=_encodings['content'])
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index b1cbc2b44..4e7777cb6 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -12,7 +12,7 @@ from itertools import chain
import portage
from portage import os
-from portage import digraph
+from portage import _unicode_decode
from portage.const import PORTAGE_PACKAGE_ATOM
from portage.dbapi import dbapi
from portage.dbapi.dep_expand import dep_expand
@@ -28,6 +28,7 @@ from portage._sets import SETPREFIX
from portage._sets.base import InternalPackageSet
from portage.util import cmp_sort_key, writemsg, writemsg_stdout
from portage.util import writemsg_level
+from portage.util.digraph import digraph
from _emerge.AtomArg import AtomArg
from _emerge.Blocker import Blocker
@@ -5027,9 +5028,10 @@ class depgraph(object):
if verbosity == 3:
writemsg_stdout('\n%s\n' % (counters,), noiselevel=-1)
if show_repos:
- # In python-2.x, str() can trigger a UnicodeEncodeError here,
- # so call __str__() directly.
- writemsg_stdout(repo_display.__str__(), noiselevel=-1)
+ # Use _unicode_decode() to force unicode format string so
+ # that RepoDisplay.__unicode__() is called in python2.
+ writemsg_stdout(_unicode_decode("%s") % (repo_display,),
+ noiselevel=-1)
if "--changelog" in self._frozen_config.myopts:
writemsg_stdout('\n', noiselevel=-1)