Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(38327)

Unified Diff: Modules/_csv.c

Issue 18829: csv produces confusing error message when passed a non-string delimiter
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_csv.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Modules/_csv.c Sun Sep 08 14:14:38 2013 +0200
+++ b/Modules/_csv.c Sun Sep 08 23:01:25 2013 +0800
@@ -239,11 +239,16 @@
*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,
- "\"%s\" must be an 1-character string",
- name);
+ if (len > 1 || (strcmp(name, "quotechar") && len==0)) {
+ PyErr_Format(PyExc_ValueError,
+ "\"%s\" must be an 1-character string", name);
return -1;
}
/* PyUnicode_READY() is called in PyUnicode_GetLength() */
« no previous file with comments | « Lib/test/test_csv.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+