Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d45a8d

Browse files
committed
Fix logic problem in quoting=csv.QUOTE_ALL, quotechar=None check, add test.
1 parent c89f284 commit 5d45a8d

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/test/test_csv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def _test_arg_valid(self, ctor, arg):
3232
self.assertRaises(TypeError, ctor, arg, quoting=None)
3333
self.assertRaises(TypeError, ctor, arg,
3434
quoting=csv.QUOTE_ALL, quotechar='')
35+
self.assertRaises(TypeError, ctor, arg,
36+
quoting=csv.QUOTE_ALL, quotechar=None)
3537

3638
def test_reader_arg_valid(self):
3739
self._test_arg_valid(csv.reader, [])

Modules/_csv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
401401
PyErr_SetString(PyExc_TypeError, "delimiter must be set");
402402
goto err;
403403
}
404-
if (quotechar == Py_None && self->quoting != QUOTE_NONE)
404+
if (quotechar == Py_None && quoting == NULL)
405405
self->quoting = QUOTE_NONE;
406406
if (self->quoting != QUOTE_NONE && self->quotechar == 0) {
407407
PyErr_SetString(PyExc_TypeError,

0 commit comments

Comments
 (0)