From f68f0da3eb5556640e8f4e64d8b49cb87959b954 Mon Sep 17 00:00:00 2001 From: milde Date: Thu, 16 May 2013 20:38:43 +0000 Subject: Fix [ 210 ] Python 3.3 checks CVS syntax only if "strict" is True. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@7662 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- HISTORY.txt | 4 ++++ docutils/parsers/rst/directives/tables.py | 2 ++ test/test_parsers/test_rst/test_directives/test_tables.py | 14 +++++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index caf27367c..82dd9112c 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -35,6 +35,10 @@ Changes Since 0.10 - Apply [ 3599485 ] node source/line information for sphinx translation. +* docutils/parsers/rst/directives/tables.py + + - Fix [ 210 ] Python 3.3 checks CVS syntax only if "strict" is True. + * docutils/parsers/rst/states.py - Fix [ 157 ] Line block parsing doesn't like system message. diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 0758f82e5..f17e76e6f 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -164,6 +164,7 @@ class CSVTable(Table): quotechar = '"' doublequote = True skipinitialspace = True + strict = True lineterminator = '\n' quoting = csv.QUOTE_MINIMAL @@ -189,6 +190,7 @@ class CSVTable(Table): escapechar = '\\' doublequote = False skipinitialspace = True + strict = True lineterminator = '\n' quoting = csv.QUOTE_MINIMAL diff --git a/test/test_parsers/test_rst/test_directives/test_tables.py b/test/test_parsers/test_rst/test_directives/test_tables.py index 924cf7793..e0b378554 100755 --- a/test/test_parsers/test_rst/test_directives/test_tables.py +++ b/test/test_parsers/test_rst/test_directives/test_tables.py @@ -10,7 +10,7 @@ Tests for tables.py directives. from __init__ import DocutilsTestSupport -import os +import os, sys import csv from docutils.parsers.rst.directives import tables @@ -32,6 +32,10 @@ if isinstance(unichr_exception, OverflowError): else: unichr_exception_string = str(unichr_exception) +csv_eod_error_str = "unexpected end of data" +if sys.version_info < (3,3): + csv_eod_error_str = "newline inside string" + def null_bytes(): import csv csv_data = open(utf_16_csv, 'rb').read() @@ -760,12 +764,12 @@ u"""\ Error with CSV data in "csv-table" directive: - newline inside string + %s .. csv-table:: bad CSV data \n\ "bad", \"csv, data -"""], +""" % csv_eod_error_str], ["""\ .. csv-table:: bad CSV header data :header: "bad", \"csv, data @@ -777,13 +781,13 @@ u"""\ Error with CSV data in "csv-table" directive: - newline inside string + %s .. csv-table:: bad CSV header data :header: "bad", \"csv, data \n\ good, csv, data -"""], +""" % csv_eod_error_str], ["""\ .. csv-table:: bad encoding :file: %s -- cgit v1.2.1