diff options
author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2014-03-20 10:51:10 +0000 |
---|---|---|
committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2014-03-20 10:51:10 +0000 |
commit | a20bee62cf2b0e0c9bb321aab20c33ff74e21672 (patch) | |
tree | a1287370b891c98e10c40e722510503892335603 /docutils/parsers/rst | |
parent | 77a5c58ef45ee2ecee24c36b18d63339a0294901 (diff) | |
download | docutils-a20bee62cf2b0e0c9bb321aab20c33ff74e21672.tar.gz |
Address [ 249 ] and [ 250 ]. CSV table fails on python 2 with unicode.
While the problem of Unicode characters in the options under Python 2
cannot be solved with reasonable effort, the patch improves error reporting
and documents the limitation.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@7747 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/parsers/rst')
-rw-r--r-- | docutils/parsers/rst/directives/tables.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index f17e76e6f..16284f77a 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -170,14 +170,14 @@ class CSVTable(Table): def __init__(self, options): if 'delim' in options: - self.delimiter = str(options['delim']) + self.delimiter = CSVTable.encode_for_csv(options['delim']) if 'keepspace' in options: self.skipinitialspace = False if 'quote' in options: - self.quotechar = str(options['quote']) + self.quotechar = CSVTable.encode_for_csv(options['quote']) if 'escape' in options: self.doublequote = False - self.escapechar = str(options['escape']) + self.escapechar = CSVTable.encode_for_csv(options['escape']) csv.Dialect.__init__(self) @@ -225,9 +225,12 @@ class CSVTable(Table): except SystemMessagePropagation, detail: return [detail.args[0]] except csv.Error, detail: + message = str(detail) + if sys.version_info < (3,) and '1-character string' in message: + message += '\nwith Python 2.x this must be an ASCII character.' error = self.state_machine.reporter.error( 'Error with CSV data in "%s" directive:\n%s' - % (self.name, detail), nodes.literal_block( + % (self.name, message), nodes.literal_block( self.block_text, self.block_text), line=self.lineno) return [error] table = (col_widths, table_head, table_body) |