Use writemsg_stdout() for safe unicode output.
authorZac Medico <zmedico@gentoo.org>
Fri, 7 Aug 2009 22:37:44 +0000 (22:37 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 7 Aug 2009 22:37:44 +0000 (22:37 -0000)
svn path=/main/trunk/; revision=13948

pym/_emerge/depgraph.py

index 3d126ad00a9b1daed9a226e7371b13a27c1309ab..bbc3cd439d6a7f42f49a5e5e5843feb26b455313 100644 (file)
@@ -22,7 +22,7 @@ from portage.output import bold, blue, colorize, create_color_func, darkblue, \
 bad = create_color_func("BAD")
 from portage.sets import SETPREFIX
 from portage.sets.base import InternalPackageSet
-from portage.util import cmp_sort_key, writemsg
+from portage.util import cmp_sort_key, writemsg, writemsg_stdout
 
 from _emerge.AtomArg import AtomArg
 from _emerge.Blocker import Blocker
@@ -4354,16 +4354,7 @@ class depgraph(object):
                if "--changelog" in self._frozen_config.myopts:
                        print
                        for revision,text in changelogs:
-
-                               if sys.hexversion < 0x3000000:
-                                       # avoid potential UnicodeEncodeError
-                                       if isinstance(revision, unicode):
-                                               revision = revision.encode('utf_8', 'replace')
-                                       if isinstance(text, unicode):
-                                               text = text.encode('utf_8', 'replace')
-
-                               print bold('*'+revision)
-                               sys.stdout.write(text)
+                               writemsg_stdout(bold('*'+revision) + '\n' + text)
 
                sys.stdout.flush()
                return os.EX_OK
@@ -5120,13 +5111,8 @@ def show_masked_packages(masked_packages):
 
                print "- "+cpv+" (masked by: "+", ".join(mreasons)+")"
 
-               if sys.hexversion < 0x3000000 and isinstance(comment, unicode):
-                       # avoid potential UnicodeEncodeError
-                       comment = comment.encode('utf_8', 'replace')
-
                if comment and comment not in shown_comments:
-                       print filename+":"
-                       print comment
+                       writemsg_stdout(filename + ":\n" + comment + "\n")
                        shown_comments.add(comment)
                portdb = root_config.trees["porttree"].dbapi
                for l in missing_licenses: