Your message dated Thu, 04 Aug 2011 06:18:03 +0000
with message-id <[email protected]>
and subject line Bug#597249: fixed in python-debian 0.1.21
has caused the Debian Bug report #597249,
regarding deb822: Native parser incorrectly handles values that start with ':'
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 [email protected]
immediately.)


-- 
597249: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597249
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: python-debian
Version: 0.1.16
Severity: normal

It appears that the deb822.Deb822.iter_paragraph method gets confused
if there are bogus entries (like a single line) in the file. Below is
a test that shows the behavior. Depending on the policy the excpeted
value is either 2 or 3 (2 if we want to discard invalid stanzas).

It appears that the problem is "while len(x) != 0" in deb822.py, that
will make the parser stop on the first bogus line. Attached is a
possible patch for this that makes the EOF handling explicit. 

Thanks,
 Michael

--- a/lib/debian/deb822.py      2010-03-16 02:06:28.000000000 +0100
+++ b/lib/debian/deb822.py      2010-06-10 10:51:30.000000000 +0200
@@ -241,7 +241,7 @@
             (All values are given back as unicode objects, so an encoding is
             necessary in order to properly interpret the strings.)
         """
-
+        self.eof = False
         if hasattr(sequence, 'items'):
             _dict = sequence
             sequence = None
@@ -249,12 +249,11 @@
             _dict = None
         Deb822Dict.__init__(self, _dict=_dict, _parsed=_parsed, _fields=fields,
                             encoding=encoding)
-
         if sequence is not None:
             try:
                 self._internal_parser(sequence, fields)
             except EOFError:
-                pass
+                self.eof = True
 
         self.gpg_info = None
 
@@ -285,7 +284,7 @@
         else:
             iterable = iter(sequence)
             x = cls(iterable, fields, encoding=encoding)
-            while len(x) != 0:
+            while not x.eof:
                 yield x
                 x = cls(iterable, fields, encoding=encoding)
 


--- a/tests/test_deb822.py      2010-03-16 02:06:28.000000000 +0100
+++ b/tests/test_deb822.py      2010-06-10 09:59:59.000000000 +0200
@@ -235,6 +235,12 @@
 -----END PGP SIGNATURE-----
 '''
 
+BOGUS_DATA = '''
+
+xxx-bogus-entry
+
+'''
+
 class TestDeb822Dict(unittest.TestCase):
     def make_dict(self):
         d = deb822.Deb822Dict()
@@ -705,6 +711,15 @@
         self.assertEqual(utf8_contents, latin1_to_utf8.getvalue())
         self.assertEqual(latin1_contents, utf8_to_latin1.getvalue())
 
+    def test_bogus(self):
+        text = (UNPARSED_PACKAGE + '\n\n\n' + 
+                BOGUS_DATA + '\n\n\n' + 
+                UNPARSED_PACKAGE).splitlines()
+        l = []
+        for d in deb822.Deb822.iter_paragraphs(text, use_apt_pkg=True):
+            l.append(d)
+        self.assertEqual(len(l), 3)
+
 class TestPkgRelations(unittest.TestCase):
 
     def test_packages(self):


-- System Information:
Debian Release: squeeze/sid
  APT prefers maverick
  APT policy: (500, 'maverick'), (500, 'lucid-security'), (500, 'lucid')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-22-generic (SMP w/2 CPU cores)
Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages python-debian depends on:
ii  python                 2.6.5-0ubuntu1    An interactive high-level object-o
ii  python-apt             0.7.94.2ubuntu6.1 Python interface to libapt-pkg
ii  python-support         1.0.4ubuntu1      automated rebuilding support for P

python-debian recommends no packages.

Versions of packages python-debian suggests:
ii  gpgv                     1.4.10-2ubuntu1 GNU privacy guard - signature veri

-- no debconf information



--- End Message ---
--- Begin Message ---
Source: python-debian
Source-Version: 0.1.21

We believe that the bug you reported is fixed in the latest version of
python-debian, which is due to be installed in the Debian FTP archive:

python-debian_0.1.21.dsc
  to main/p/python-debian/python-debian_0.1.21.dsc
python-debian_0.1.21.tar.gz
  to main/p/python-debian/python-debian_0.1.21.tar.gz
python-debian_0.1.21_all.deb
  to main/p/python-debian/python-debian_0.1.21_all.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
John Wright <[email protected]> (supplier of updated python-debian package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Wed, 03 Aug 2011 23:07:17 -0700
Source: python-debian
Binary: python-debian
Architecture: source all
Version: 0.1.21
Distribution: unstable
Urgency: low
Maintainer: Debian python-debian Maintainers 
<[email protected]>
Changed-By: John Wright <[email protected]>
Description: 
 python-debian - Python modules to work with Debian-related data formats
Closes: 597120 597249 625672 627058 627060 627063 631392 632306
Changes: 
 python-debian (0.1.21) unstable; urgency=low
 .
   [ Tshepang Lekhonkhobe ]
   * test_changelog.py: Close open files. (Closes: #625672)
 .
   [ John Wright ]
   * deb822: Allow ':' as the first character of a value.
     (Closes: #597249)
   * deb822: Avoid dumping unparseable data. (Closes: #597120)
   * Clean up deb822.GpgInfo implementation:
     - Change several @staticmethod decorated methods to @classmethod,
       since they call the class constructor.
     - from_sequence now can accept both sequences of newline-terminated
       strings and the output of str.splitlines().
     - from_file now actually calls the from_sequence method.
       (Closes: #627058)
     - from_sequence now makes a copy of the initial args list before
       extending it. (Closes: #627060)
     - Keyrings are no longer checked for accessibility, since gpgv can
       accept keyring arguments that are under the GnuPG home directory,
       regardless of the current directory. (Closes: #627063)
   * deb822.Deb822.gpg_info takes an optional keyrings argument.
   * deb822: Don't interpret lines starting with '#'. (Closes: #632306)
 .
   [ Colin Watson ]
   * Use dh_python2 instead of python-support. (Closes: #631392)
Checksums-Sha1: 
 d55cecd66ac8dd41ede6f7e65b9d89896c9a02ca 1227 python-debian_0.1.21.dsc
 a4216be3f1a8855e5d5784aa9faa08f74a80beb2 184663 python-debian_0.1.21.tar.gz
 28a7477ea774592e8341c4c7dfdc1ed276dc5f5e 61300 python-debian_0.1.21_all.deb
Checksums-Sha256: 
 bdc7c07e18593be4f64fca45fa8a563836980058b0ac3700cc3c9177917bc46a 1227 
python-debian_0.1.21.dsc
 0ca7bf4808e2a056853319122e5f17cea0f62492cb23a7ef910f314f54476dac 184663 
python-debian_0.1.21.tar.gz
 59e38e88cec8d4f9d7432061d1e4f6352913290d14f01e7f21646f4d65b2a774 61300 
python-debian_0.1.21_all.deb
Files: 
 c67928ca46db93ecc378e72082786c51 1227 python optional python-debian_0.1.21.dsc
 dcbf7f8294108f179509c822d1d57caa 184663 python optional 
python-debian_0.1.21.tar.gz
 4886dca98fc3ad8fc84098c9bd44162b 61300 python optional 
python-debian_0.1.21_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk46N+4ACgkQ0UIZh3p4ZWEYegCeJk3BYi8o6ttRv8LHYJx+AXBB
GhkAn335mDkjGRTvmikYGVtibSk4HsWU
=j4Jx
-----END PGP SIGNATURE-----



--- End Message ---

Reply via email to