From 0d622864bf45b2826335b3be31330829f43db7cd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Sep 2010 16:55:43 +0200 Subject: merged patch from Samuel Lidén Borell to fix crash if there utf8 in the control file (LP: #624290) and add test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apt/debfile.py | 2 +- debian/changelog | 2 ++ tests/data/test_debs/utf8-package_1.0-1_all.deb | Bin 0 -> 1150 bytes tests/test_debfile.py | 7 +++++++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/data/test_debs/utf8-package_1.0-1_all.deb diff --git a/apt/debfile.py b/apt/debfile.py index 73f7d88e..1e7a66cc 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -66,7 +66,7 @@ class DebPackage(object): self._debfile = apt_inst.DebFile(open(self.filename)) control = self._debfile.control.extractdata("control") # hm, 'replace' is probably better but python2.6 test fail with that - self._sections = apt_pkg.TagSection(control.decode("UTF-8", 'ignore')) + self._sections = apt_pkg.TagSection(control) self.pkgname = self._sections["Package"] def __getitem__(self, key): diff --git a/debian/changelog b/debian/changelog index 7fd04b41..d23bd54a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,8 @@ python-apt (0.7.97) UNRELEASED; urgency=low * add "provides" property to the apt.Version objects * apt/debfile.py: - fix error when reading binary content and add regresion test + * merged patch from Samuel Lidén Borell to fix crash if there utf8 + in the control file (LP: #624290) and add test -- Julian Andres Klode Fri, 23 Jul 2010 16:14:39 +0200 diff --git a/tests/data/test_debs/utf8-package_1.0-1_all.deb b/tests/data/test_debs/utf8-package_1.0-1_all.deb new file mode 100644 index 00000000..e0339c2e Binary files /dev/null and b/tests/data/test_debs/utf8-package_1.0-1_all.deb differ diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 42cda6f6..571c2ec9 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -1,4 +1,5 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- # # Copyright (C) 2010 Michael Vogt # @@ -77,6 +78,12 @@ class TestDebfilee(unittest.TestCase): "Unexpected result for package '%s' (got %s wanted %s)\n%s" % ( filename, res, expected_res, deb._failure_string)) + def test_utf8_sections(self): + deb = apt.debfile.DebPackage(cache=self.cache) + deb.open(os.path.join("data","test_debs","utf8-package_1.0-1_all.deb")) + self.assertEqual(deb["Maintainer"], + "Samuel Lidén Borell ") + def testContent(self): # normal deb = apt.debfile.DebPackage(cache=self.cache) -- cgit v1.2.3