From 36a7691c2dc4a11ceebacb149e69b01226962d69 Mon Sep 17 00:00:00 2001 From: Andrew McNamara Date: Mon, 10 Jan 2005 01:04:40 +0000 Subject: Fix parsing of csv files with escapes (escape character previously would be left in stream). --- Lib/test/test_csv.py | 4 ++-- Modules/_csv.c | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py index 6c47c6e..66b0ea9 100644 --- a/Lib/test/test_csv.py +++ b/Lib/test/test_csv.py @@ -227,10 +227,10 @@ class Test_Csv(unittest.TestCase): self.assertRaises(csv.Error, self._read_test, ['a,b\r\nc,d'], []) def test_read_escape(self): - self._read_test(['a,\\b,c'], [['a', '\\b', 'c']], escapechar='\\') + self._read_test(['a,\\b,c'], [['a', 'b', 'c']], escapechar='\\') self._read_test(['a,b\\,c'], [['a', 'b,c']], escapechar='\\') self._read_test(['a,"b\\,c"'], [['a', 'b,c']], escapechar='\\') - self._read_test(['a,"b,\\c"'], [['a', 'b,\\c']], escapechar='\\') + self._read_test(['a,"b,\\c"'], [['a', 'b,c']], escapechar='\\') self._read_test(['a,"b,c\\""'], [['a', 'b,c"']], escapechar='\\') self._read_test(['a,"b,c"\\'], [['a', 'b,c\\']], escapechar='\\') diff --git a/Modules/_csv.c b/Modules/_csv.c index 893a273..13445b8 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -584,10 +584,6 @@ parse_process_char(ReaderObj *self, char c) break; case ESCAPED_CHAR: - if (c != dialect->escapechar && - c != dialect->delimiter && - c != dialect->quotechar) - parse_add_char(self, dialect->escapechar); parse_add_char(self, c); self->state = IN_FIELD; break; @@ -642,10 +638,6 @@ parse_process_char(ReaderObj *self, char c) break; case ESCAPE_IN_QUOTED_FIELD: - if (c != dialect->escapechar && - c != dialect->delimiter && - c != dialect->quotechar) - parse_add_char(self, dialect->escapechar); parse_add_char(self, c); self->state = IN_QUOTED_FIELD; break; -- cgit v0.12