Your message dated Tue, 11 Jun 2019 22:04:09 +0200 with message-id <246c6f03-244b-1900-ab4d-d12aadc9b209@debian.org> and subject line Re: unblock: python-debian/0.1.35 has caused the Debian Bug report #929722, regarding unblock: python-debian/0.1.35 to be marked as done. This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact owner@bugs.debian.org immediately.) -- 929722: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=929722 Debian Bug Tracking System Contact owner@bugs.debian.org with problems
--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: unblock: python-debian/0.1.35
- From: Stuart Prescott <stuart@debian.org>
- Date: Thu, 30 May 2019 00:36:36 +1000
- Message-id: <155914059670.24899.8626200813426432501.reportbug@simurgh.nanonanonano.net>
Package: release.debian.org Severity: normal User: release.debian.org@packages.debian.org Usertags: unblock Dear Release Team, There are two important bugs in python-debian that I would like to fix in buster. I don't think the changes are sufficiently large or problematic to prevent that, but I seek your pre-approval for them prior to uploading (diff against 0.1.34 attached). * debian_support.PackageFile is completely broken with non-ASCII Packages and Sources files when used with Python 3. (#928655) * when processing debian/copyright files, NotMachineReadableError is not raised when the file is not copyright-format/1.0. (not filed in the bts, MR submitted directly, would be severity:important since it makes the debian.copyright module almost unusable for consumers like sources.debian.net) There are additionally two other minor bugs that are already fixed in git. Fixing them seems reasonable to me but your input is sought. * Stop using the deprecated autopkgtest needs-recommends restriction. * Prevent accidental overwriting of abc.Mapping and typing.Mapping with Python 3. regards Stuart unblock python-debian/0.1.35 -- System Information: Debian Release: 10.0 APT prefers testing APT policy: (550, 'testing'), (500, 'testing-proposed-updates'), (500, 'testing-debug'), (500, 'testing') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.19.0-4-amd64 (SMP w/4 CPU cores) Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE=en_AU:en (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enableddiff --git a/debian/changelog b/debian/changelog index 5d1db94..60d9f95 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,18 @@ +python-debian (0.1.35) unstable; urgency=medium + + [ Stuart Prescott ] + * Fix decode error when using debian_support.PackageFile by allowing the + caller to specify an encoding, defaulting to UTF-8 (Closes: #928655). + * Remove needs-recommends from autopkgtest definitions. + + [ Jan Teske ] + * Fix overwriting of names in importing abc.Mapping and typing.Mapping. + + [ Jelmer Vernooij ] + * Correctly raise NotMachineReadableError when no format is set. + + -- Stuart Prescott <stuart@debian.org> Thu, 30 May 2019 00:23:06 +1000 + python-debian (0.1.34) unstable; urgency=medium [ Jelmer Vernooij ] diff --git a/debian/tests/control b/debian/tests/control index ecb50a4..386071d 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -1,17 +1,19 @@ Tests: python3-debian -Restrictions: allow-stderr needs-recommends +Restrictions: allow-stderr Depends: binutils (>= 2.23), python3-all, + python3-apt, python3-debian, debian-keyring, debian-archive-keyring Tests: python-debian -Restrictions: allow-stderr needs-recommends +Restrictions: allow-stderr Depends: binutils (>= 2.23), python2.7, + python-apt, python-debian, python-unittest2, debian-keyring, diff --git a/lib/debian/copyright.py b/lib/debian/copyright.py index cfe587b..d360784 100644 --- a/lib/debian/copyright.py +++ b/lib/debian/copyright.py @@ -639,7 +639,7 @@ class Header(deb822.RestrictedWrapper): super(Header, self).__init__(data) fmt = self.format # type: ignore - if fmt != _CURRENT_FORMAT: + if fmt != _CURRENT_FORMAT and fmt is not None: # Add a terminal slash onto the end if missing if not fmt.endswith('/'): fmt += "/" diff --git a/lib/debian/deb822.py b/lib/debian/deb822.py index 3dbd41c..0686cdb 100644 --- a/lib/debian/deb822.py +++ b/lib/debian/deb822.py @@ -222,16 +222,11 @@ from __future__ import absolute_import, print_function import collections try: # Python 3 - from collections.abc import ( - Mapping, - MutableMapping, - ) + import collections.abc as collections_abc except ImportError: # Python 2.7 cruft - from collections import ( - Mapping, - MutableMapping, - ) + # pylint: disable=reimported + import collections as collections_abc # type: ignore import datetime import email.utils @@ -321,7 +316,7 @@ class RestrictedFieldError(Error): """Raised when modifying the raw value of a field is not allowed.""" -class TagSectionWrapper(Mapping): +class TagSectionWrapper(collections_abc.Mapping): """Wrap a TagSection object, using its find_raw method to get field values This allows us to pick which whitespace to strip off the beginning and end @@ -423,7 +418,7 @@ class OrderedSet(object): # ### -class Deb822Dict(MutableMapping): +class Deb822Dict(collections_abc.MutableMapping): """A dictionary-like object suitable for storing RFC822-like data. Deb822Dict behaves like a normal dict, except: diff --git a/lib/debian/debian_support.py b/lib/debian/debian_support.py index 851eb90..cf4a26e 100644 --- a/lib/debian/debian_support.py +++ b/lib/debian/debian_support.py @@ -379,7 +379,7 @@ class PackageFile: re_field = re.compile(r'^([A-Za-z][A-Za-z0-9-_]+):(?:\s*(.*?))?\s*$') re_continuation = re.compile(r'^\s+(?:\.|(\S.*?)\s*)$') - def __init__(self, name, file_obj=None): + def __init__(self, name, file_obj=None, encoding="utf-8"): """Creates a new package file object. name - the name of the file the data comes from @@ -387,13 +387,14 @@ class PackageFile: file with the indicated name. """ if file_obj is None: - file_obj = open(name) + file_obj = open(name, 'rb') self.name = name self.file = file_obj self.lineno = 0 + self.encoding = encoding def __iter__(self): - line = self.file.readline().decode() + line = self.file.readline().decode(self.encoding) self.lineno += 1 pkg = [] while line: @@ -402,7 +403,7 @@ class PackageFile: self.raise_syntax_error('expected package record') yield pkg pkg = [] - line = self.file.readline().decode() + line = self.file.readline().decode(self.encoding) self.lineno += 1 continue @@ -413,7 +414,7 @@ class PackageFile: contents = contents or '' while True: - line = self.file.readline().decode() + line = self.file.readline().decode(self.encoding) self.lineno += 1 match = self.re_continuation.match(line) if match: diff --git a/lib/debian/tests/test_copyright.py b/lib/debian/tests/test_copyright.py index 9361866..3f2953c 100755 --- a/lib/debian/tests/test_copyright.py +++ b/lib/debian/tests/test_copyright.py @@ -687,6 +687,11 @@ class HeaderTest(unittest.TestCase): h.format = None self.assertEqual(('value must not be None',), cm.exception.args) + def test_format_upgrade_no_header(self): + data = deb822.Deb822() + with self.assertRaises(copyright.NotMachineReadableError): + copyright.Header(data=data) + def test_format_https_upgrade(self): data = deb822.Deb822() data['Format'] = "http%s" % FORMAT[5:] diff --git a/lib/debian/tests/test_debian_support.py b/lib/debian/tests/test_debian_support.py index bf268de..acb17a5 100755 --- a/lib/debian/tests/test_debian_support.py +++ b/lib/debian/tests/test_debian_support.py @@ -246,5 +246,23 @@ class PdiffTests(unittest.TestCase): os.remove(copy) +class PackageFileTests(unittest.TestCase): + """ Tests for functions dealing with Packages and Sources """ + + def test_read_file(self): + # test_Packages is ASCII + packfile = find_test_file('test_Packages') + pf = debian_support.PackageFile(packfile) + pflist = list(pf) + self.assertEqual(len(pflist), 3) + + # test_Sources is UTF-8 + # test for bad decoding, #928655 + packfile = find_test_file('test_Sources') + pf = debian_support.PackageFile(packfile) + pflist = list(pf) + self.assertEqual(len(pflist), 4) + + if __name__ == "__main__": unittest.main()
--- End Message ---
--- Begin Message ---
- To: 929722-done@bugs.debian.org, Stuart Prescott <stuart@debian.org>
- Subject: Re: unblock: python-debian/0.1.35
- From: Paul Gevers <elbrus@debian.org>
- Date: Tue, 11 Jun 2019 22:04:09 +0200
- Message-id: <246c6f03-244b-1900-ab4d-d12aadc9b209@debian.org>
- In-reply-to: <[🔎] ff6c5556-7a39-37af-1640-e74c2e4d2332@debian.org>
- References: <155914059670.24899.8626200813426432501.reportbug@simurgh.nanonanonano.net> <155914059670.24899.8626200813426432501.reportbug@simurgh.nanonanonano.net> <[🔎] ff6c5556-7a39-37af-1640-e74c2e4d2332@debian.org>
Hi Stuart, On 06-06-2019 16:54, Paul Gevers wrote: > Please go ahead and remove the moreinfo tag once there is something to > unblock. Somehow this was forgotten. However, unblocked, thanks. PaulAttachment: signature.asc
Description: OpenPGP digital signature
--- End Message ---