diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2012-09-25 09:37:20 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2012-09-25 09:37:20 (GMT) |
commit | 49d130227b8ab6e24044e4da3b9c44a68d4e6bea (patch) | |
tree | 7262f3b275e1ad480078fd1591bdccb6a835093c /Modules | |
parent | 9118a79c7c410d71725cd52cde310c8e224ac8f0 (diff) | |
parent | 67b7b98a479a5703a5707b6ea0cf81d3e0b441ea (diff) | |
download | cpython-49d130227b8ab6e24044e4da3b9c44a68d4e6bea.zip cpython-49d130227b8ab6e24044e4da3b9c44a68d4e6bea.tar.gz cpython-49d130227b8ab6e24044e4da3b9c44a68d4e6bea.tar.bz2 |
merge 3.2: Issue #16013: Fix CSV Reader parsing issue with ending quote characters. Patch by Serhiy Storchaka.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_csv.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index 8380990..cc87bad 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -788,9 +788,14 @@ Reader_iternext(ReaderObj *self) lineobj = PyIter_Next(self->input_iter); if (lineobj == NULL) { /* End of input OR exception */ - if (!PyErr_Occurred() && self->field_len != 0) - PyErr_Format(_csvstate_global->error_obj, - "newline inside string"); + if (!PyErr_Occurred() && (self->field_len != 0 || + self->state == IN_QUOTED_FIELD)) { + if (self->dialect->strict) + PyErr_SetString(_csvstate_global->error_obj, + "unexpected end of data"); + else if (parse_save_field(self) >= 0) + break; + } return NULL; } if (!PyUnicode_Check(lineobj)) { |