summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-10-07 19:30:39 (GMT)
committerGitHub <noreply@github.com>2022-10-07 19:30:39 (GMT)
commite73cb54a063ddfc1530031e95c23209ed2883a82 (patch)
tree29058a064c75c2bcc8539d6e04663f2bb68c51d5
parent7565944994a98f0c78026487009d90661b94e4b7 (diff)
downloadcpython-e73cb54a063ddfc1530031e95c23209ed2883a82.zip
cpython-e73cb54a063ddfc1530031e95c23209ed2883a82.tar.gz
cpython-e73cb54a063ddfc1530031e95c23209ed2883a82.tar.bz2
gh-65496: Correct wording on csv's skipinitialspace argument (GH-96170)
(cherry picked from commit 676d8ef3806758bcd1d3fd84a746c8a9b64480d0) Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
-rw-r--r--Doc/library/csv.rst2
-rw-r--r--Lib/test/test_csv.py5
-rw-r--r--Modules/_csv.c8
3 files changed, 10 insertions, 5 deletions
diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst
index 899ce02..3a41ae2 100644
--- a/Doc/library/csv.rst
+++ b/Doc/library/csv.rst
@@ -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`.
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index d94a6f2..623a6b6 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -335,6 +335,11 @@ class Test_Csv(unittest.TestCase):
['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.
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 72f0791..c991968 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -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 */
@@ -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"