~ubuntu-branches/ubuntu/trusty/python-docutils/trusty

« back to all changes in this revision

Viewing changes to debian/patches/strict-csv-parser.diff

  • Committer: Package Import Robot
  • Author(s): Dmitry Shachnev
  • Date: 2013-05-17 16:47:30 UTC
  • mfrom: (20.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20130517164730-5ux7p59z0jdku6pf
Tags: 0.10-3ubuntu1
* Merge with Debian unstable, remaining changes:
  - Use dh_python2 instead of dh_pysupport.
  - Backport patch to support embedded aliases in references
    (support-aliases-in-references.diff).
* disable_py33_failing_tests.diff: dropped, the issue is now
  properly fixed in Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: make the CSV parser stricter
 
2
 Make the CSV parser stricter. Update the tests so that they take into that
 
3
 CSV syntax error message may vary with Python version.
 
4
Author: Jakub Wilk <jwilk@debian.org>
 
5
Forwarded: yes
 
6
Bug: http://sourceforge.net/p/docutils/bugs/210/
 
7
Bug-Debian: http://bugs.debian.org/692286 
 
8
Last-Update: 2013-05-16
 
9
 
 
10
--- a/docutils/parsers/rst/directives/tables.py
 
11
+++ b/docutils/parsers/rst/directives/tables.py
 
12
@@ -166,6 +166,7 @@
 
13
         skipinitialspace = True
 
14
         lineterminator = '\n'
 
15
         quoting = csv.QUOTE_MINIMAL
 
16
+        strict = True
 
17
 
 
18
         def __init__(self, options):
 
19
             if 'delim' in options:
 
20
@@ -191,6 +192,7 @@
 
21
         skipinitialspace = True
 
22
         lineterminator = '\n'
 
23
         quoting = csv.QUOTE_MINIMAL
 
24
+        strict = True
 
25
 
 
26
     def check_requirements(self):
 
27
         pass
 
28
--- a/test/test_parsers/test_rst/test_directives/test_tables.py
 
29
+++ b/test/test_parsers/test_rst/test_directives/test_tables.py
 
30
@@ -42,6 +42,12 @@
 
31
 
 
32
 null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes)[0]
 
33
 
 
34
+def unexpected_eod():
 
35
+    reader = csv.reader(['"\n'], strict=1)
 
36
+    reader.next()
 
37
+
 
38
+unexpected_eod_exception = DocutilsTestSupport.exception_data(unexpected_eod)[0]
 
39
+
 
40
 totest = {}
 
41
 
 
42
 totest['table'] = [
 
43
@@ -760,12 +766,12 @@
 
44
     <system_message level="3" line="1" source="test data" type="ERROR">
 
45
         <paragraph>
 
46
             Error with CSV data in "csv-table" directive:
 
47
-            newline inside string
 
48
+            %s
 
49
         <literal_block xml:space="preserve">
 
50
             .. csv-table:: bad CSV data
 
51
             \n\
 
52
                "bad", \"csv, data
 
53
-"""],
 
54
+""" % unexpected_eod_exception],
 
55
 ["""\
 
56
 .. csv-table:: bad CSV header data
 
57
    :header: "bad", \"csv, data
 
58
@@ -777,13 +783,13 @@
 
59
     <system_message level="3" line="1" source="test data" type="ERROR">
 
60
         <paragraph>
 
61
             Error with CSV data in "csv-table" directive:
 
62
-            newline inside string
 
63
+            %s
 
64
         <literal_block xml:space="preserve">
 
65
             .. csv-table:: bad CSV header data
 
66
                :header: "bad", \"csv, data
 
67
             \n\
 
68
                good, csv, data
 
69
-"""],
 
70
+""" % unexpected_eod_exception],
 
71
 ["""\
 
72
 .. csv-table:: bad encoding
 
73
    :file: %s