Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-132813: Fix the csv documentation for quoting and escaping#133209

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugovk merged 3 commits intopython:mainfromserhiy-storchaka:docs-csv-quoting
Jun 30, 2025

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedApr 30, 2025
edited by github-actionsbot
Loading

quotechar and new-line characters are always quoted or escaped. escapechar is always escaped.


📚 Documentation preview 📚:https://cpython-previews--133209.org.readthedocs.build/

quotechar and new-line characters are always quoted or escaped.escapechar is always escaped.
@vadimkantorov
Copy link

What can also be surprising is different behavior forquotechar="" andquotechar=None. I would make them behave the same (currentlyquotechar="" is not permitted), but it's very subjective indeed

@serhiy-storchaka
Copy link
MemberAuthor

It was. In the past,"" and"\0" were interpreted asNone fordelimiter,quotechar andescapechar. But it was confusing, and it was impossible to use the null character as the delimiter or whatever.

@vadimkantorov
Copy link

@serhiy-storchaka IIUC,quote_char=None is accepted forQUOTE_NONE, butquote_char="" is not, because there is a check that if it's astr, it must be a 1-charstr. For me the fact thatquote_char=None is accepted, butquote_char="" is not is strange (not talking here about the null character"\0", just about empty string)

@serhiy-storchakaserhiy-storchaka added the needs backport to 3.14bugs and security fixes labelMay 8, 2025
@serhiy-storchakaserhiy-storchaka requested a review froma teamMay 13, 2025 10:35
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`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I do not understand this part of the sentence in the original, nor the addition below.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

How would you write it?

Different characters are escaped depending on different conditions:

  • ifquoting is set to :const:QUOTE_NONE, it escapesdelimiter,quotechar, etc.
  • ifdoublequote is False, it escapesquotechar.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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

serhiy-storchaka reacted with thumbs up emoji
Copy link
Member

@terryjreedyterryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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.

vadimkantorov reacted with thumbs up emoji
@bedevere-app
Copy link

When you're done making the requested changes, leave the comment:I have made the requested changes; please review again.

@vadimkantorov
Copy link

vadimkantorov commentedMay 13, 2025
edited
Loading

It would be nice if the docs mentioned explicitly thatquotechar=None is also allowed. Currently:
image

which says that "empty" is not allowed, whatever that might be meaning (and many people would considerNone to also qualify as "empty")

@serhiy-storchaka
Copy link
MemberAuthor

This what this PR does.

vadimkantorov reacted with heart emoji

@serhiy-storchaka
Copy link
MemberAuthor

I have made the requested changes; please review again.

@bedevere-app
Copy link

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@terryjreedyterryjreedy dismissed theirstale reviewJune 30, 2025 02:46

Sentence changed and is now clearer.

@hugovkhugovk merged commit536a5ff intopython:mainJun 30, 2025
31 of 32 checks passed
@github-project-automationgithub-project-automationbot moved this fromTodo toDone inDocs PRsJun 30, 2025
@miss-islington-app
Copy link

Thanks@serhiy-storchaka for the PR, and@hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJun 30, 2025
…ythonGH-133209)(cherry picked from commit536a5ff)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJun 30, 2025
…ythonGH-133209)(cherry picked from commit536a5ff)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app
Copy link

GH-136113 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJun 30, 2025
@bedevere-app
Copy link

GH-136114 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelJun 30, 2025
hugovk pushed a commit that referenced this pull requestJun 30, 2025
hugovk pushed a commit that referenced this pull requestJun 30, 2025
@serhiy-storchakaserhiy-storchaka deleted the docs-csv-quoting branchJuly 1, 2025 17:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@vadimkantorovvadimkantorovvadimkantorov left review comments

@aterrelaterrelaterrel approved these changes

@hugovkhugovkhugovk approved these changes

@terryjreedyterryjreedyterryjreedy approved these changes

Assignees
No one assigned
Labels
docsDocumentation in the Doc dirskip news
Projects
Status: Done
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@serhiy-storchaka@vadimkantorov@aterrel@hugovk@terryjreedy

[8]ページ先頭

©2009-2025 Movatter.jp