Skip to content

Commit 676d8ef

Browse files
authored
gh-65496: Correct wording on csv's skipinitialspace argument (#96170)
1 parent 4a74e6a commit 676d8ef

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Doc/library/csv.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ Dialects support the following attributes:
420420

421421
.. attribute:: Dialect.skipinitialspace
422422

423-
When :const:`True`, whitespace immediately following the *delimiter* is ignored.
423+
When :const:`True`, spaces immediately following the *delimiter* are ignored.
424424
The default is :const:`False`.
425425

426426

Lib/test/test_csv.py

+5
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ def test_read_quoting(self):
362362
self._read_test(['1,@,3,@,5'], [['1', ',3,', '5']], quotechar='@')
363363
self._read_test(['1,\0,3,\0,5'], [['1', ',3,', '5']], quotechar='\0')
364364

365+
def test_read_skipinitialspace(self):
366+
self._read_test(['no space, space, spaces,\ttab'],
367+
[['no space', 'space', 'spaces', '\ttab']],
368+
skipinitialspace=True)
369+
365370
def test_read_bigfield(self):
366371
# This exercises the buffer realloc functionality and field size
367372
# limits.

Modules/_csv.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ parse_process_char(ReaderObj *self, _csvstate *module_state, Py_UCS4 c)
704704
self->state = ESCAPED_CHAR;
705705
}
706706
else if (c == ' ' && dialect->skipinitialspace)
707-
/* ignore space at start of field */
707+
/* ignore spaces at start of field */
708708
;
709709
else if (c == dialect->delimiter) {
710710
/* save empty field */
@@ -1647,9 +1647,9 @@ PyDoc_STRVAR(csv_module_doc,
16471647
" quoting character. It defaults to '\"'.\n"
16481648
" * delimiter - specifies a one-character string to use as the\n"
16491649
" field separator. It defaults to ','.\n"
1650-
" * skipinitialspace - specifies how to interpret whitespace which\n"
1651-
" immediately follows a delimiter. It defaults to False, which\n"
1652-
" means that whitespace immediately following a delimiter is part\n"
1650+
" * skipinitialspace - specifies how to interpret spaces which\n"
1651+
" immediately follow a delimiter. It defaults to False, which\n"
1652+
" means that spaces immediately following a delimiter is part\n"
16531653
" of the following field.\n"
16541654
" * lineterminator - specifies the character sequence which should\n"
16551655
" terminate rows.\n"

0 commit comments

Comments
 (0)