process_control: do not encode to ascii
authorHelmut Grohne <helmut@subdivi.de>
Thu, 16 Apr 2015 15:58:56 +0000 (17:58 +0200)
committerHelmut Grohne <helmut@subdivi.de>
Thu, 16 Apr 2015 15:58:56 +0000 (17:58 +0200)
Otherwise the yaml will contain binary strings on py3k which end up as
binary data in the sqlite database. In py2, yaml can handle those
unicode objects just fine.

dedup/debpkg.py

index dbee849..8f2121b 100644 (file)
@@ -9,15 +9,15 @@ def process_control(control_contents):
     @rtype: {str: object}
     """
     control = deb822.Packages(control_contents)
-    package = control["package"].encode("ascii")
+    package = control["package"]
     try:
-        source = control["source"].encode("ascii").split()[0]
+        source = control["source"].split()[0]
     except KeyError:
         source = package
-    version = control["version"].encode("ascii")
-    architecture = control["architecture"].encode("ascii")
+    version = control["version"]
+    architecture = control["architecture"]
     # deb822 currently returns :any dependencies raw. see #670679
-    depends = set(dep[0]["name"].split(u':', 1)[0].encode("ascii")
+    depends = set(dep[0]["name"].split(u':', 1)[0]
                   for dep in control.relations.get("depends", ())
                   if len(dep) == 1)
     return dict(package=package, source=source, version=version,