Skip to content

Commit

Permalink
pythongh-65496: Correct wording on csv's skipinitialspace argument (p…
Browse files Browse the repository at this point in the history
…ythonGH-96170)

(cherry picked from commit 676d8ef)

Co-authored-by: Stanley <[email protected]>
  • Loading branch information
slateny authored and miss-islington committed Oct 7, 2022
1 parent da986c6 commit 49c8dfa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Doc/library/csv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ Dialects support the following attributes:

.. attribute:: Dialect.skipinitialspace

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


Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ def test_read_quoting(self):
['abc,3'], [[]],
quoting=csv.QUOTE_NONNUMERIC)

def test_read_skipinitialspace(self):
self._read_test(['no space, space, spaces,\ttab'],
[['no space', 'space', 'spaces', '\ttab']],
skipinitialspace=True)

def test_read_bigfield(self):
# This exercises the buffer realloc functionality and field size
# limits.
Expand Down
8 changes: 4 additions & 4 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ parse_process_char(ReaderObj *self, _csvstate *module_state, Py_UCS4 c)
self->state = ESCAPED_CHAR;
}
else if (c == ' ' && dialect->skipinitialspace)
/* ignore space at start of field */
/* ignore spaces at start of field */
;
else if (c == dialect->delimiter) {
/* save empty field */
Expand Down Expand Up @@ -1603,9 +1603,9 @@ PyDoc_STRVAR(csv_module_doc,
" quoting character. It defaults to '\"'.\n"
" * delimiter - specifies a one-character string to use as the\n"
" field separator. It defaults to ','.\n"
" * skipinitialspace - specifies how to interpret whitespace which\n"
" immediately follows a delimiter. It defaults to False, which\n"
" means that whitespace immediately following a delimiter is part\n"
" * skipinitialspace - specifies how to interpret spaces which\n"
" immediately follow a delimiter. It defaults to False, which\n"
" means that spaces immediately following a delimiter is part\n"
" of the following field.\n"
" * lineterminator - specifies the character sequence which should\n"
" terminate rows.\n"
Expand Down

0 comments on commit 49c8dfa

Please sign in to comment.