-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-12178: Fix escaping of escapechar in csv.writer() #13710
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
Conversation
Since only the quote and escape chars should be escaped, perhaps add a test that other special characters, i.e. delimiters and line terminators, aren't? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Lib/test/test_csv.py
Outdated
(['a/', 1], '"a//",1', csv.QUOTE_MINIMAL), | ||
(['a/', 1], 'a//,1', csv.QUOTE_NONE), | ||
(['a/', 1], '"a//","1"', csv.QUOTE_ALL), | ||
(['a/b', 1], '"a//b",1', csv.QUOTE_MINIMAL), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are quotes needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@serhiy-storchaka, your question is unclear to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the output is "a//b",1
instead of just a//b,1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! I'm wondering the same thing now. Might just be a bug!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem consistent with the docs:
Instructs
writer
objects to only quote those fields which contain special characters such as delimiter, quotechar or any of the characters in lineterminator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree there shouldn't be quotes here. They should be removed from the tests (and implemented correctly) before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed now. Please take a look again.
I'm going to take a look at the PR this weekend. Sorry for my late response. |
@berkerpeksag, let me know if there's any way I can help this get into 3.8. |
Ping? We already missed 3.8, let's not miss 3.9! |
4c46836
to
ea956f0
Compare
Co-Authored-By: Itay Elbirt <[email protected]>
ea956f0
to
df92090
Compare
Ping, @berkerpeksag? |
I've already addressed review comments back in July. |
Ah, sorry, you're right, I missed that! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closing and re-opening to re-run the stalled Travis-CI check. |
@berkerpeksag, what do you think about whether this should be back-ported? While it's obviously a bug-fix, I'm conflicted since this could break code which relied on the existing behavior. |
I agree with you. I'm totally fine with either backporting to only 3.9 or no backport. |
3.9.0rc2 is out and only critical fixes should go into 3.9.0, and I wouldn't want this in 3.9.1 but not 3.9.0. So let's avoid back-porting. |
Co-authored-by: Itay Elbirt <[email protected]>
https://bugs.python.org/issue12178