]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-65496: Correct wording on csv's skipinitialspace argument (#96170)
authorStanley <46876382+slateny@users.noreply.github.com>
Fri, 7 Oct 2022 18:15:34 +0000 (11:15 -0700)
committerGitHub <noreply@github.com>
Fri, 7 Oct 2022 18:15:34 +0000 (11:15 -0700)
Doc/library/csv.rst
Lib/test/test_csv.py
Modules/_csv.c

index 0cab95e1500a6659c5821fea41dc57bc8b1591c7..41f11505aa10309a02dc8dac2d3e07ca9d793b5f 100644 (file)
@@ -420,7 +420,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`.
 
 
index a2b00430c7dd6021ed573f102da80d92bec42901..d64bff13a44e877a6f195a3d7edf6417817ecc1b 100644 (file)
@@ -362,6 +362,11 @@ class Test_Csv(unittest.TestCase):
         self._read_test(['1,@,3,@,5'], [['1', ',3,', '5']], quotechar='@')
         self._read_test(['1,\0,3,\0,5'], [['1', ',3,', '5']], quotechar='\0')
 
+    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.
index d34d0a1296ae72991caacadfc60e78dd1d233044..25bf86f78e8fb9a2558e2a77ed2fb8f942d98d2f 100644 (file)
@@ -704,7 +704,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 */
@@ -1647,9 +1647,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"