bpo-29869: Allow underscores in numeric literals in lib2to3. by nevsan · Pull Request #752 · python/cpython (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation10 Commits3 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
I found this while debugging google/yapf#370. The fix is quite simple and quick.
Hello, and thanks for your contribution!
I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).
Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow these steps to rectify the issue:
- Sign the PSF contributor agreement. The "bugs.python.org username" requested by the form is the "Login name" field in "Your Details" at b.p.o
- Wait at least one US business day and then check the "Contributor form received entry under "Your Details" on bugs.python.org to see if your account has been marked as having signed the CLA (the delay is due to a person having to manually check your signed CLA)
- Reply here saying you have completed the above steps
Thanks again to your contribution and we look forward to looking at it!
I have completed the above steps.
nevsan changed the title
Allow underscores in numeric literals in lib2to3. bpo-29869: Allow underscores in numeric literals in lib2to3.
The existing regular expressions weren't actually strict enough as is, so I made them even more correct. In particular, we must have at least one digit following 0[xXbBoO]
and must be before any underscores.
I have a small set of test cases to examine correctness of these regular expressions: https://gist.github.com/nevsan/7fc78dc61d309842406d67d6839b9861
Updated regular expressions to avoid catastrophic backtracking. Gist updated with new test cases (still passes).
@nevsan looks like Travis disagrees that the tests still pass 😉
Took a few iterations, but I managed to fix up the regexes. I also added a test case to test numeric literals with underscores (and verified that it fails for the un-patched HEAD).
@rhettinger would you mind officially registering your review approval? You can do that by going under "Files changed", clicking the green "Review changes", and then you can choose "Approve" and submit the review. Perk of this is your approval will show up under Reviewers so if another core dev has the time to merge and backport they know someone else already cleared the code.
Mariatta added a commit that referenced this pull request
@nevsan Can you create the PR against the master
branch?
Mariatta added a commit that referenced this pull request
This reverts commit 97a40b7. The commit is supposed to go to the master branch first.
Labels
An unexpected behavior, bug, or error