diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2012-09-25 02:48:21 -0700 |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2012-09-25 02:48:21 -0700 |
commit | d41dc7ce468edda4172c228dae949a477d8ab03d (patch) | |
tree | 0f36656353d3079cac8c8fdeb4af8fef3109ef3e /Modules/_csv.c | |
parent | 3dec449a7c18be320427d813bcbd1368dee6a8aa (diff) | |
download | cpython-git-d41dc7ce468edda4172c228dae949a477d8ab03d.tar.gz |
2.7 : Issue #16013: Fix CSV Reader parsing issue with ending quote characters. Patch by Serhiy Storchaka.
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r-- | Modules/_csv.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index ab2a5ed8d2..fd6121fccf 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -788,9 +788,13 @@ 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(error_obj, - "newline inside string"); + if (!PyErr_Occurred() && (self->field_len != 0 || + self->state == IN_QUOTED_FIELD)) { + if (self->dialect->strict) + PyErr_SetString(error_obj, "unexpected end of data"); + else if (parse_save_field(self) >= 0 ) + break; + } return NULL; } ++self->line_num; |