From: Zac Medico Date: Thu, 16 Sep 2010 11:09:06 +0000 (-0700) Subject: Make RepoDisplay __str__ and __unicode__ methods more like X-Git-Tag: v2.2_rc84~35 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0a00c6f1d01487299f05da6d6f5dbd9f5ff764f9;p=portage.git Make RepoDisplay __str__ and __unicode__ methods more like DependencyArg. --- 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)