summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-12-19 14:27:18 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-12-19 14:27:18 (GMT)
commitcac23a50ee2979b8c2e3472e6b13efb1a8bd4f78 (patch)
tree4844c5601937d1b2b23bde82ceecb030564e9425 /Modules
parent800e11b4065185e8b6ccbd4ad15134c0a885b7e7 (diff)
downloadcpython-cac23a50ee2979b8c2e3472e6b13efb1a8bd4f78.zip
cpython-cac23a50ee2979b8c2e3472e6b13efb1a8bd4f78.tar.gz
cpython-cac23a50ee2979b8c2e3472e6b13efb1a8bd4f78.tar.bz2
Issue #18829: csv.Dialect() now checks type for delimiter, escapechar and
quotechar fields. Original patch by Vajrasky Kok.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_csv.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 48a5cf8..f5f6e71 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -239,6 +239,12 @@ _set_char(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt)
*target = '\0';
if (src != Py_None) {
Py_ssize_t len;
+ if (!PyUnicode_Check(src)) {
+ PyErr_Format(PyExc_TypeError,
+ "\"%s\" must be string, not %.200s", name,
+ src->ob_type->tp_name);
+ return -1;
+ }
len = PyUnicode_GetLength(src);
if (len > 1) {
PyErr_Format(PyExc_TypeError,
@@ -425,7 +431,8 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
if (dialect_check_quoting(self->quoting))
goto err;
if (self->delimiter == 0) {
- PyErr_SetString(PyExc_TypeError, "delimiter must be set");
+ PyErr_SetString(PyExc_TypeError,
+ "\"delimiter\" must be an 1-character string");
goto err;
}
if (quotechar == Py_None && quoting == NULL)