-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
csv.skipinitialspace only skips spaces, not "whitespace" in general #65496
Comments
Regarding the
and the
"Whitespace" is a bit too general in both cases (at least a red herring in the second case), since it only skips spaces and not e.g. tabs 1. In
and the actual implementation at line 638:
No-one will probably assume that the whole UTF-8 spectrum of "whitespace" is skipped, but at least I initially assumed that the tab character was included. |
Do I understand correctly that only one space is ignored? |
No, multiple spaces are ignored as advertised (according to actual tests; not just reading the code), but only spaces (U+0020) and not e.g. tabs (U+0009), which are also included in the term "whitespace", along with several other characters. In light of your followup question, the internal comment at
could perhaps be clarified to say "spaces" instead of "space", but the code context makes it quite clear, and it does not face the users anyway. The main point of this issue is meant to be the wording in the module docstring and the official docs regarding "whitespace" contra "space". |
This code shows what Daniel Andersson was talking about. I changed the "whitespace" references in the documentation that Daniel mentioned to say spaces. Also I changed "ignore space at the start of the field" to "ignore spaces at the start of the field" due to Terry's confusion. Let me know of any errors or extra changes that are needed. |
The patch looks good to me, thanks! Could you also convert your test script to a test case and add it in Lib/test/test_csv.py? |
This is my first attempt at working with the test suite but I believe this is what you were asking for. Due to this being my first attempt at writing tests I have included it as a separate patch file. Any further changes just let me know. |
…ythonGH-96170) (cherry picked from commit 676d8ef) Co-authored-by: Stanley <[email protected]>
…ythonGH-96170) (cherry picked from commit 676d8ef) Co-authored-by: Stanley <[email protected]>
(cherry picked from commit 676d8ef) Co-authored-by: Stanley <[email protected]>
(cherry picked from commit 676d8ef) Co-authored-by: Stanley <[email protected]>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: