Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-155087: Add ternary conditional operator (?:) and $-prefix None-declaration syntax#155089
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
b156e63cae3525594b91f136490f97998dd4e3560f36151f5File 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -59,6 +59,8 @@ RARROW '->' | ||
| ELLIPSIS '...' | ||
| COLONEQUAL ':=' | ||
| EXCLAMATION '!' | ||
| DOLLAR '$' | ||
| TERNARY '?' | ||
| OP | ||
| TYPE_IGNORE | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
When callers parse with an older grammar via
PyCF_ONLY_AST/ast.parse(..., feature_version=(3, 15)), this rule still acceptsa ? b : cbecause it constructsIfExpdirectly instead of usingCHECK_VERSION. Since this tree is already Python 3.16 (PY_MINOR_VERSIONis 16), the new?:syntax (and the new$statement rule) should be wrapped in a version check so tools that request an older grammar continue to reject it.Useful? React with 👍 / 👎.