[Python-checkins] python/nondist/sandbox/csv _csv.c,1.30,1.31
andrewmcnamara@users.sourceforge.net
andrewmcnamara@users.sourceforge.net
Thu, 13 Feb 2003 22:32:42 -0800
Update of /cvsroot/python/python/nondist/sandbox/csv
In directory sc8-pr-cvs1:/tmp/cvs-serv30254
Modified Files:
_csv.c
Log Message:
Catch the case where a multi-line field is not completed before hitting
end of input and raise an exception. Fixed missing check on string
conversion in reader.
Index: _csv.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/csv/_csv.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** _csv.c 13 Feb 2003 16:02:50 -0000 1.30
--- _csv.c 14 Feb 2003 06:32:40 -0000 1.31
***************
*** 625,630 ****
do {
lineobj = PyIter_Next(self->input_iter);
! if (!lineobj)
return NULL;
if (self->had_parse_error) {
--- 625,635 ----
do {
lineobj = PyIter_Next(self->input_iter);
! if (lineobj == NULL) {
! /* End of input OR exception */
! if (!PyErr_Occurred() && self->field_len != 0)
! return PyErr_Format(error_obj,
! "newline inside string");
return NULL;
+ }
if (self->had_parse_error) {
***************
*** 638,641 ****
--- 643,650 ----
}
line = PyString_AsString(lineobj);
+ if (line == NULL) {
+ Py_DECREF(lineobj);
+ return NULL;
+ }
/* Process line of text - send '\0' to processing code to
***************
*** 1046,1051 ****
return 0;
! return PyEval_CallFunction(self->writeline,
! "(s#)", self->rec, self->rec_len);
}
--- 1055,1060 ----
return 0;
! return PyObject_CallFunction(self->writeline,
! "(s#)", self->rec, self->rec_len);
}