Package: python-support
Version: 1.0.6
Severity: minor
Tags: patch
User: [email protected]
Usertags: origin-ubuntu ubuntu-patch lucid
Hi
When parsing debian/control, parseversions shouldn't allow for
XS-Python-Version to be in any debian/control paragraph, but only in
the first one. See also #567941.
I'm attaching a proposed patch to fix parsing and another patch to add
a testsuite.
Thanks,
NB: for convenience, I imported the SVN repo of python-support at
https://code.launchpad.net/~lool/python-support/trunk and these patches
are in
https://code.launchpad.net/~lool/python-support/parseversions-control-syntax
--
Loïc Minier
=== modified file 'parseversions'
--- parseversions 2009-05-12 18:43:27 +0000
+++ parseversions 2010-02-02 21:06:51 +0000
@@ -30,7 +30,13 @@
if options.pycentral:
import re
l=None
+ paraborder=True
for line in f:
+ if line=="\n":
+ if paraborder==True:
+ continue
+ break
+ paraborder=False
if line.startswith("XS-Python-Version:"):
l=line.split(':')[1]
break
=== added file 'testparseversions.leading-newline.control'
--- testparseversions.leading-newline.control 1970-01-01 00:00:00 +0000
+++ testparseversions.leading-newline.control 2010-02-02 21:10:28 +0000
@@ -0,0 +1,5 @@
+
+Source: source
+XS-Python-Version: >= 2.6
+
+Package: package
=== added file 'testparseversions.missing.control'
--- testparseversions.missing.control 1970-01-01 00:00:00 +0000
+++ testparseversions.missing.control 2010-02-02 21:10:28 +0000
@@ -0,0 +1,3 @@
+Source: source
+
+Package: package
=== added file 'testparseversions.py'
--- testparseversions.py 1970-01-01 00:00:00 +0000
+++ testparseversions.py 2010-02-02 21:10:28 +0000
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+import unittest
+import subprocess
+
+class TestParseVersions(unittest.TestCase):
+ def get_output(self, control):
+ subp = subprocess.Popen(["./parseversions", "--pycentral", control],
+ stdout=subprocess.PIPE)
+ output = subp.communicate()[0]
+ if subp.returncode != 0:
+ raise RuntimeError, subp.returncode
+ return output
+
+ def test_regular(self):
+ self.assertEqual(self.get_output('testparseversions.regular.control'), '2.6\n')
+
+ def test_leading_newline(self):
+ self.assertEqual(self.get_output('testparseversions.leading-newline.control'), '2.6\n')
+
+ def test_missing(self):
+ self.assertRaises(RuntimeError, self.get_output, 'testparseversions.missing.control')
+
+ def test_second_paragraph(self):
+ self.assertRaises(RuntimeError, self.get_output, 'testparseversions.second-paragraph.control')
+
+if __name__ == '__main__':
+ unittest.main()
=== added file 'testparseversions.regular.control'
--- testparseversions.regular.control 1970-01-01 00:00:00 +0000
+++ testparseversions.regular.control 2010-02-02 21:10:28 +0000
@@ -0,0 +1,4 @@
+Source: source
+XS-Python-Version: >= 2.6
+
+Package: package
=== added file 'testparseversions.second-paragraph.control'
--- testparseversions.second-paragraph.control 1970-01-01 00:00:00 +0000
+++ testparseversions.second-paragraph.control 2010-02-02 21:10:28 +0000
@@ -0,0 +1,4 @@
+Source: source
+
+Package: package
+XS-Python-Version: >= 2.6