Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
gh-109638: Fix for significant backtracking in csv.Sniffer#109639
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes from3 commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -270,8 +270,9 @@ def _guess_quote_and_delimiter(self, data, delimiters): | ||
# if we see an extra quote between delimiters, we've got a | ||
# double quoted format | ||
# in future Python versions this zero width look-ahead assert can be replaced with atomic groups | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Please may you explain this comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Sure, this zero-width lookahead assertion change in the Regex can be done with an atomic group which is cleaner and more concise.
But atomic groups are only supported in Python 3.11 onwards so I avoided using them here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Thanks Sean. This PR (if merged) would be part of Python 3.13, so let's use the better atomic group method. A There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Sure, I've switched us to the simpler atomic group setup. Performance is identical to the previous fix. | ||
dq_regexp = re.compile( | ||
r"((%(delim)s)|^)\W*%(quote)s(?=(?P<zero>[^%(delim)s%(quote)s\n]*))(?P=zero)%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)" % \ | ||
{'delim':re.escape(delim), 'quote':quotechar}, re.MULTILINE) | ||