[PATCH 1/4] Make sure we work with strings when we think we do

Vratislav Podzimek vpodzime at redhat.com
Mon Dec 8 09:35:44 UTC 2014


Instead of relying on RPM returning us something that really works like a
string, let's just make sure we have a real string in both Python[23].

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 meh/dump.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/meh/dump.py b/meh/dump.py
index 4a31a7f..fa72238 100644
--- a/meh/dump.py
+++ b/meh/dump.py
@@ -154,20 +154,22 @@ class ExceptionDump(object):
             except StopIteration:
                 raise RPMinfoError("Cannot get package and component for file "+
                         "{0}".format(file_))
-            pkg_info = PackageInfo(header["name"], header["version"],
-                                   header["release"], header["epoch"] or "0",
-                                   header["arch"])
+            pkg_info = PackageInfo(header["name"].decode("utf-8"), header["version"].decode("utf-8"),
+                                   header["release"].decode("utf-8"),
+                                   header["epoch"].decode("utf-8") if header["epoch"] else "0",
+                                   header["arch"].decode("utf-8"))
 
             # cuts the name from the NVR format: foo-blah-2.8.8-2.fc17.src.rpm
-            name_end = len(header["sourcerpm"])
+            srpm_name = header["sourcerpm"].decode("utf-8")
+            name_end = len(srpm_name)
             try:
-                name_end = header["sourcerpm"].rindex('-')
-                name_end = header["sourcerpm"][:name_end].rindex('-')
+                name_end = srpm_name.rindex('-')
+                name_end = srpm_name[:name_end].rindex('-')
             except ValueError as e:
                 # expected exception
                 pass
 
-            component = header["sourcerpm"][:name_end]
+            component = srpm_name[:name_end]
 
             return (pkg_info, component)
 
-- 
1.9.3



More information about the anaconda-patches mailing list