[yum-cvs] yum output.py,1.78,1.79

Jeremy Katz katzj at linux.duke.edu
Thu Jun 28 15:37:03 UTC 2007


Update of /home/groups/yum/cvs/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv29478

Modified Files:
	output.py 
Log Message:
more hackery around python encoding disasters.  the strings we get back
from the rpmdb are just string objects (as opposed to unicode) but may have
utf8 content.  so if we try to encode them, we get errors.  so only encode
the unicode objects (rh#245445)


Index: output.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/output.py,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- output.py	26 Jun 2007 22:31:17 -0000	1.78
+++ output.py	28 Jun 2007 15:37:01 -0000	1.79
@@ -61,6 +61,13 @@
     
         
     def infoOutput(self, pkg):
+        def enc(s):
+            # this sucks.  what we get back from the rpmdb
+            # are strings, but they may actually have unicode so we
+            # can't encode them
+            if type(s) == unicode:
+                return s.encode("UTF-8")
+            return s
         print _("Name   : %s") % pkg.name
         print _("Arch   : %s") % pkg.arch
         if pkg.epoch != "0":
@@ -69,8 +76,8 @@
         print _("Release: %s") % pkg.release
         print _("Size   : %s") % self.format_number(float(pkg.size))
         print _("Repo   : %s") % pkg.repoid
-        print _("Summary: %s") % pkg.summary.encode("UTF-8")
-        print _("Description:\n%s") % pkg.description.encode("UTF-8")
+        print _("Summary: %s") % enc(pkg.summary)
+        print _("Description:\n%s") % enc(pkg.description)
         print ""
     
     def updatesObsoletesList(self, uotup, changetype):




More information about the Yum-cvs-commits mailing list