Skip to content

Commit c2f21af

Browse files
miss-islingtonslateny
andauthoredOct 7, 2022
gh-65496: Correct wording on csv's skipinitialspace argument (GH-96170)
(cherry picked from commit 676d8ef) Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
1 parent 17c9ce1 commit c2f21af

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
@@ -416,7 +416,7 @@ Dialects support the following attributes:
416416

417417
.. attribute:: Dialect.skipinitialspace
418418

419-
When :const:`True`, whitespace immediately following the *delimiter* is ignored.
419+
When :const:`True`, spaces immediately following the *delimiter* are ignored.
420420
The default is :const:`False`.
421421

422422

‎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)
Please sign in to comment.