Commit c74dc171 authored by Michael Vogt's avatar Michael Vogt

fix py3 issue with auto .gz decompression and add test

parent cb57a522
......@@ -27,7 +27,7 @@ import os
import sys
from apt_pkg import gettext as _
from io import StringIO
from io import BytesIO
class NoDebArchiveException(IOError):
......@@ -637,9 +637,9 @@ class DebPackage(object):
data = part.extractdata(name)
# check for zip content
if name.endswith(".gz") and auto_decompress:
io = StringIO(data)
io = BytesIO(data)
gz = gzip.GzipFile(fileobj=io)
data = _("Automatically decompressed:\n\n")
data = _("Automatically decompressed:\n\n").encode("utf-8")
data += gz.read()
# auto-convert to hex
try:
......
......@@ -178,6 +178,11 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading
"./data/test_debs/testdep-same-arch_1.0-1_i386.deb")
self.assertTrue(same.check(), same._failure_string)
def test_get_content_gzip_data(self):
deb = apt.debfile.DebPackage("./data/test_debs/gdebi-test13.deb")
data = deb.data_content("./lala.gz")
self.assertEqual(data, "Automatically decompressed:\n\nlala\n")
if __name__ == "__main__":
#logging.basicConfig(level=logging.DEBUG)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment