summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/csv.py2
-rw-r--r--Lib/test/test_csv.py14
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_csv.c12
4 files changed, 15 insertions, 15 deletions
diff --git a/Lib/csv.py b/Lib/csv.py
index aaaa3cf..14b4d17 100644
--- a/Lib/csv.py
+++ b/Lib/csv.py
@@ -6,7 +6,7 @@ csv.py - read/write/investigate CSV files
import re
from _csv import Error, __version__, writer, reader, register_dialect, \
unregister_dialect, get_dialect, list_dialects, \
- set_field_limit, \
+ field_size_limit, \
QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE, \
__doc__
from _csv import Dialect as _Dialect
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index fd26e78..be1147d 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -233,21 +233,21 @@ class Test_Csv(unittest.TestCase):
def test_read_bigfield(self):
# This exercises the buffer realloc functionality and field size
# limits.
- limit = csv.set_field_limit()
+ limit = csv.field_size_limit()
try:
size = 50000
bigstring = 'X' * size
bigline = '%s,%s' % (bigstring, bigstring)
self._read_test([bigline], [[bigstring, bigstring]])
- csv.set_field_limit(size)
+ csv.field_size_limit(size)
self._read_test([bigline], [[bigstring, bigstring]])
- self.assertEqual(csv.set_field_limit(), size)
- csv.set_field_limit(size-1)
+ self.assertEqual(csv.field_size_limit(), size)
+ csv.field_size_limit(size-1)
self.assertRaises(csv.Error, self._read_test, [bigline], [])
- self.assertRaises(TypeError, csv.set_field_limit, None)
- self.assertRaises(TypeError, csv.set_field_limit, 1, None)
+ self.assertRaises(TypeError, csv.field_size_limit, None)
+ self.assertRaises(TypeError, csv.field_size_limit, 1, None)
finally:
- csv.set_field_limit(limit)
+ csv.field_size_limit(limit)
class TestDialectRegistry(unittest.TestCase):
def test_registry_badargs(self):
diff --git a/Misc/NEWS b/Misc/NEWS
index a551d51..4bb11e4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -57,7 +57,7 @@ Library
+ a configurable limit to the size of parsed fields has been added -
previously, an unmatched quote character could result in the entire
file being read into the field buffer before an error was reported.
- + A new module method csv.set_field_limit() has been added that sets
+ + A new module method csv.field_size_limit() has been added that sets
the parser field size limit (returning the former limit). The initial
limit is 128kB.
+ reader and writer objects were not being registered with the cyclic-GC.
diff --git a/Modules/_csv.c b/Modules/_csv.c
index a433960..03b291f 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -1408,12 +1408,12 @@ csv_get_dialect(PyObject *module, PyObject *name_obj)
}
static PyObject *
-csv_set_field_limit(PyObject *module, PyObject *args)
+csv_field_size_limit(PyObject *module, PyObject *args)
{
PyObject *new_limit = NULL;
long old_limit = field_limit;
- if (!PyArg_UnpackTuple(args, "set_field_limit", 0, 1, &new_limit))
+ if (!PyArg_UnpackTuple(args, "field_size_limit", 0, 1, &new_limit))
return NULL;
if (new_limit != NULL) {
if (!PyInt_Check(new_limit)) {
@@ -1533,9 +1533,9 @@ PyDoc_STRVAR(csv_unregister_dialect_doc,
"Delete the name/dialect mapping associated with a string name.\n"
" csv.unregister_dialect(name)");
-PyDoc_STRVAR(csv_set_field_limit_doc,
+PyDoc_STRVAR(csv_field_size_limit_doc,
"Sets an upper limit on parsed fields.\n"
-" csv.set_field_limit([limit])\n"
+" csv.field_size_limit([limit])\n"
"\n"
"Returns old limit. If limit is not given, no new limit is set and\n"
"the old limit is returned");
@@ -1553,8 +1553,8 @@ static struct PyMethodDef csv_methods[] = {
METH_O, csv_unregister_dialect_doc},
{ "get_dialect", (PyCFunction)csv_get_dialect,
METH_O, csv_get_dialect_doc},
- { "set_field_limit", (PyCFunction)csv_set_field_limit,
- METH_VARARGS, csv_set_field_limit_doc},
+ { "field_size_limit", (PyCFunction)csv_field_size_limit,
+ METH_VARARGS, csv_field_size_limit_doc},
{ NULL, NULL }
};