gh-132813: Fix the csv documentation for quoting and escaping#133209
gh-132813: Fix the csv documentation for quoting and escaping#133209hugovk merged 3 commits intopython:mainfrom
Conversation
quotechar and new-line characters are always quoted or escaped. escapechar is always escaped.
|
What can also be surprising is different behavior for |
|
It was. In the past, |
|
@serhiy-storchaka IIUC, |
Doc/library/csv.rst
Outdated
| A one-character string used by the writer to escape the *delimiter*, | ||
| the *quotechar*, ``'\r'``, ``'\n'`` and any of the characters in | ||
| *lineterminator* if *quoting* is set to :const:`QUOTE_NONE`, | ||
| the *quotechar* if *doublequote* is :const:`False`, |
There was a problem hiding this comment.
I do not understand this part of the sentence in the original, nor the addition below.
There was a problem hiding this comment.
How would you write it?
Different characters are escaped depending on different conditions:
- if quoting is set to :const:
QUOTE_NONE, it escapes delimiter, quotechar, etc. - if doublequote is False, it escapes quotechar.
There was a problem hiding this comment.
Perhaps:
A one-character string for escaping. If quoting is set to :const:QUOTE_NONE, it escapes delimiter, quotechar, ``'\r'``, ``'\n'`` and any of the characters in *lineterminator*. If doublequote is False, it escapes quotechar
terryjreedy
left a comment
There was a problem hiding this comment.
I am assuming that the fact changes are correct. I code not parse one sentence before and less so now. I am guessing that it needs to be split into 2 sentences.
|
When you're done making the requested changes, leave the comment: |
|
This what this PR does. |
|
I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @terryjreedy: please review the changes made to this pull request. |
|
Thanks @serhiy-storchaka for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…ythonGH-133209) (cherry picked from commit 536a5ff) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…ythonGH-133209) (cherry picked from commit 536a5ff) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
GH-136113 is a backport of this pull request to the 3.14 branch. |
|
GH-136114 is a backport of this pull request to the 3.13 branch. |

quotechar and new-line characters are always quoted or escaped. escapechar is always escaped.
csv.writerwithQUOTE_NONEstill requires non-emtpyquotecharandescapechar#132813📚 Documentation preview 📚: https://cpython-previews--133209.org.readthedocs.build/