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 +=
# auto-convert to hex
......@@ -178,6 +178,11 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading
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__":
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