[Python-checkins] python/dist/src/Modules _csv.c,1.33,1.34
andrewmcnamara at users.sourceforge.net
andrewmcnamara at users.sourceforge.net
Wed Jan 12 12:17:48 CET 2005
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27851/Modules
Modified Files:
_csv.c
Log Message:
Add counting of source iterator lines to the reader object - handy for
user error messages (otherwise difficult to do without instrumenting
the source).
Index: _csv.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- _csv.c 12 Jan 2005 09:45:16 -0000 1.33
+++ _csv.c 12 Jan 2005 11:17:14 -0000 1.34
@@ -98,6 +98,7 @@
int field_len; /* length of current field */
int had_parse_error; /* did we have a parse error? */
int numeric_field; /* treat field as numeric */
+ unsigned long line_num; /* Source-file line number */
} ReaderObj;
staticforward PyTypeObject Reader_Type;
@@ -734,6 +735,7 @@
static struct PyMemberDef Reader_memberlist[] = {
{ "dialect", T_OBJECT, R_OFF(dialect), RO },
+ { "line_num", T_ULONG, R_OFF(line_num), RO },
{ NULL }
};
@@ -753,6 +755,7 @@
"newline inside string");
return NULL;
}
+ ++self->line_num;
if (self->had_parse_error)
if (parse_reset(self) < 0) {
@@ -924,6 +927,7 @@
self->input_iter = NULL;
self->field = NULL;
self->field_size = 0;
+ self->line_num = 0;
if (parse_reset(self) < 0) {
Py_DECREF(self);
More information about the Python-checkins
mailing list