]> git.decadent.org.uk Git - dak.git/commitdiff
Yield utf-8 encoded strings from DBBinary.scan_contents().
authorTorsten Werner <twerner@debian.org>
Fri, 4 Mar 2011 08:07:12 +0000 (09:07 +0100)
committerTorsten Werner <twerner@debian.org>
Fri, 4 Mar 2011 08:07:12 +0000 (09:07 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py

index 5bff4186df00dba323e449a482bc90c1f6eba93a..87db1a35fa1a0dda87bc5ee2237079854caae879 100755 (executable)
@@ -516,11 +516,13 @@ class DBBinary(ORMObject):
         tar = TarFile.open(fileobj = dpkg.stdout, mode = 'r|')
         for member in tar.getmembers():
             if member.isfile():
+                name = normpath(member.name)
+                # enforce proper utf-8 encoding
                 try:
-                    name = member.name.decode('utf-8')
+                    name.decode('utf-8')
                 except UnicodeDecodeError:
-                    name = member.name.decode('iso8859-1')
-                yield normpath(name)
+                    name = name.decode('iso8859-1').encode('utf-8')
+                yield name
         tar.close()
         dpkg.stdout.close()
         dpkg.wait()