Skip to content

Commit e73cb54

Browse files
gh-65496: Correct wording on csv's skipinitialspace argument (GH-96170)
(cherry picked from commit 676d8ef) Co-authored-by: Stanley <[email protected]>
1 parent 7565944 commit e73cb54

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Doc/library/csv.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ Dialects support the following attributes:
412412

413413
.. attribute:: Dialect.skipinitialspace
414414

415-
When :const:`True`, whitespace immediately following the *delimiter* is ignored.
415+
When :const:`True`, spaces immediately following the *delimiter* are ignored.
416416
The default is :const:`False`.
417417

418418

Lib/test/test_csv.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ def test_read_quoting(self):
335335
['abc,3'], [[]],
336336
quoting=csv.QUOTE_NONNUMERIC)
337337

338+
def test_read_skipinitialspace(self):
339+
self._read_test(['no space, space, spaces,\ttab'],
340+
[['no space', 'space', 'spaces', '\ttab']],
341+
skipinitialspace=True)
342+
338343
def test_read_bigfield(self):
339344
# This exercises the buffer realloc functionality and field size
340345
# limits.

Modules/_csv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ parse_process_char(ReaderObj *self, _csvstate *module_state, Py_UCS4 c)
698698
self->state = ESCAPED_CHAR;
699699
}
700700
else if (c == ' ' && dialect->skipinitialspace)
701-
/* ignore space at start of field */
701+
/* ignore spaces at start of field */
702702
;
703703
else if (c == dialect->delimiter) {
704704
/* save empty field */
@@ -1603,9 +1603,9 @@ PyDoc_STRVAR(csv_module_doc,
16031603
" quoting character. It defaults to '\"'.\n"
16041604
" * delimiter - specifies a one-character string to use as the\n"
16051605
" field separator. It defaults to ','.\n"
1606-
" * skipinitialspace - specifies how to interpret whitespace which\n"
1607-
" immediately follows a delimiter. It defaults to False, which\n"
1608-
" means that whitespace immediately following a delimiter is part\n"
1606+
" * skipinitialspace - specifies how to interpret spaces which\n"
1607+
" immediately follow a delimiter. It defaults to False, which\n"
1608+
" means that spaces immediately following a delimiter is part\n"
16091609
" of the following field.\n"
16101610
" * lineterminator - specifies the character sequence which should\n"
16111611
" terminate rows.\n"

0 commit comments

Comments
 (0)