-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-46820: Fix a SyntaxError in a numeric literal followed by "not in" #31479
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
Fix parsing a numeric literal immediately (without spaces) followed by "not in" keywords, like in "1not in x". Now the parser only emits a warning, not a syntax error.
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
Thanks for the quick fix @serhiy-storchaka ! 🎉
check("0not in x") | ||
check("1.not in x") | ||
check("1e3not in x") | ||
check("1jnot in x") |
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.
Small nit: At this point maybe we want to make these strings dynamically:
for infix in ["and", "or", "in", "not in"]:
check(f"0xf{infix} x")
check(f"0o7{infix} x")
check(f"0b1{infix} x")
check(f"9{infix} x")
check(f"0{infix} x")
check(f"1.{infix} x")
check(f"1e3{infix} x")
check(f"1j{infix} x")
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.
I'll rewrite tests in a separate PR.
check("0not in x") | ||
check("1.not in x") | ||
check("1e3not in x") | ||
check("1jnot in x") |
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.
Maybe add a test with an underscore literal, just for completeness' sake?
check("1jnot in x") | |
check("1jnot in x") | |
check("1_000not in x") |
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
GH-31493 is a backport of this pull request to the 3.10 branch. |
pythonGH-31479) Fix parsing a numeric literal immediately (without spaces) followed by "not in" keywords, like in "1not in x". Now the parser only emits a warning, not a syntax error. (cherry picked from commit 090e5c4) Co-authored-by: Serhiy Storchaka <[email protected]>
xref #31494 |
GH-31479) (GH-31493) Fix parsing a numeric literal immediately (without spaces) followed by "not in" keywords, like in "1not in x". Now the parser only emits a warning, not a syntax error. (cherry picked from commit 090e5c4) Co-authored-by: Serhiy Storchaka <[email protected]>
Fix parsing a numeric literal immediately (without spaces) followed by
"not in" keywords, like in "1not in x". Now the parser only emits
a warning, not a syntax error.
https://bugs.python.org/issue46820