[PATCH] Basic support for non-ascii package names. BZ 1039276

Zdenek Pavlas zpavlas at redhat.com
Tue Dec 10 09:55:27 UTC 2013


Not sure how useful is this, but individual changes are probably ok,
and the test RPM did install, reinstall and remove just fine.
---
 output.py              | 7 +++++--
 yum/history.py         | 1 +
 yum/packages.py        | 3 +++
 yum/transactioninfo.py | 3 +++
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/output.py b/output.py
index 041910c..de77d69 100755
--- a/output.py
+++ b/output.py
@@ -1482,6 +1482,7 @@ class YumOutput:
 
         def _add_line(lines, data, a_wid, po, obsoletes=[]):
             (n,a,e,v,r) = po.pkgtup
+            n = to_unicode(n)
             evr = po.printVer()
             repoid = po.ui_from_repo
             pkgsize = float(po.size)
@@ -1708,6 +1709,7 @@ Transaction Summary
                 out += '\n%s:\n' % action
                 for txmbr in pkglist:
                     (n,a,e,v,r) = txmbr.pkgtup
+                    n = to_unicode(n)
                     msg = "%s.%s %s:%s-%s" % (n,a,e,v,r)
                     msgs.append(msg)
                 for num in (8, 7, 6, 5, 4, 3, 2):
@@ -2894,7 +2896,7 @@ class DepSolveProgressCallBack:
 
         yb = self.ayum
 
-        prob_pkg = "%s (%s)" % (reqPo, reqPo.ui_from_repo)
+        prob_pkg = u"%s (%s)" % (reqPo, reqPo.ui_from_repo)
         msg = _('Package: %s') % (prob_pkg,)
         ui_req = formatRequire(needname, needversion, needflags)
         msg += _('\n    Requires: %s') % (ui_req,)
@@ -3211,13 +3213,14 @@ class YumCliRPMCallBack(RPMBaseCallback):
     def _out_event(self, te_current, te_total, ts_current, ts_total,
                    percent, process, pkgname, wid1):
         if self.output and (sys.stdout.isatty() or te_current == te_total):
+            pkgname = to_unicode(pkgname)
             (fmt, wid1, wid2) = self._makefmt(percent, ts_current, ts_total,
                                               progress=sys.stdout.isatty(),
                                               pkgname=pkgname, wid1=wid1)
             msg = fmt % (utf8_width_fill(process, wid1, wid1),
                          utf8_width_fill(pkgname, wid2, wid2))
             if msg != self.lastmsg:
-                sys.stdout.write(to_unicode(msg))
+                sys.stdout.write(msg)
                 sys.stdout.flush()
                 self.lastmsg = msg
             if te_current == te_total:
diff --git a/yum/history.py b/yum/history.py
index 6f60f54..6fc1ecd 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -726,6 +726,7 @@ class YumHistory:
             except (sqlite.OperationalError, sqlite.DatabaseError):
                 self.conf.readable = False
                 return None
+            self._conn.text_factory = str
 
             #  Note that this is required due to changing the history DB in the
             # callback for removed txmbrs ... which happens inside the chroot,
diff --git a/yum/packages.py b/yum/packages.py
index cc1f1e3..247ca6d 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -330,6 +330,9 @@ class PackageObject(object):
                                    self.arch)
     envra = property(fget=lambda self: self._envra())
 
+    def __unicode__(self):
+        return str(self).decode('UTF-8')
+
     def __str__(self):
         return self.ui_envra
 
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index d34f3a8..2cabfc9 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -864,6 +864,9 @@ class TransactionMember:
     def __hash__(self):
         return object.__hash__(self)
             
+    def __unicode__(self):
+        return str(self).decode('UTF-8')
+
     def __str__(self):
         return "%s.%s %s:%s-%s - %s" % (self.name, self.arch, self.epoch,
                                         self.version, self.release, self.ts_state)
-- 
1.7.11.7



More information about the Yum-devel mailing list