Skip to content

Commit d8e5209

Browse files
author
Rémi Lapeyre
committed
Address review comments
1 parent f2d530f commit d8e5209

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎Doc/library/csv.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ Reader objects have the following public attributes:
419419

420420
.. attribute:: csvreader.field_size_limit
421421

422-
The maximum field size allowed by this reader. If :const:`None`,
423-
*csv.field_size_limit()* is used.
422+
The maximum field size allowed by this reader. If :const:`None`,
423+
csv.field_size_limit() is used.
424424

425425
DictReader objects have the following public attribute:
426426

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
`csv.field_size_limit` can now be overriden for each csv.Reader
1+
``csv.field_size_limit`` can now be overriden for each csv.Reader
22
instance. Contributed by Rémi Lapeyre.

‎Modules/_csv.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,10 @@ parse_grow_buff(ReaderObj *self)
573573
static int
574574
parse_add_char(ReaderObj *self, Py_UCS4 c)
575575
{
576-
long limit = self->field_limit == -1 ? _csvstate_global->field_limit : self->field_limit;
576+
long limit = self->field_limit;
577+
if (limit == -1) {
578+
limit = _csvstate_global->field_limit;
579+
}
577580
if (self->field_len >= limit) {
578581
PyErr_Format(_csvstate_global->error_obj, "field larger than field limit (%ld)",
579582
limit);
@@ -1023,8 +1026,7 @@ csv_reader(PyObject *module, PyObject *args, PyObject *keyword_args)
10231026
}
10241027
self->field_limit = limit;
10251028
}
1026-
Py_DECREF(_field_size_limit);
1027-
_field_size_limit = NULL;
1029+
Py_CLEAR(_field_size_limit);
10281030

10291031
if (parse_reset(self) < 0) {
10301032
goto fail;
@@ -1746,7 +1748,7 @@ PyInit__csv(void)
17461748
return NULL;
17471749

17481750
/* Add the CSV exception object to the module. */
1749-
_csvstate(module)->error_obj = PyErr_NewException("csv.Error", NULL, NULL);
1751+
_csvstate(module)->error_obj = PyErr_NewException("_csv.Error", NULL, NULL);
17501752
if (_csvstate(module)->error_obj == NULL)
17511753
return NULL;
17521754
Py_INCREF(_csvstate(module)->error_obj);

0 commit comments

Comments
 (0)