-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-129515: Clarify syntax error messages for conditional expressions #129880
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
gh-129515: Clarify syntax error messages for conditional expressions #129880
Conversation
test_fstring fails, will dig |
…y-miryanov/cpython into pythongh-129515-ifexp-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.
Left some new comments
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
- also reword error messages - move tests to test_syntax - update whatsnew and news
I have made the requested changes; please review again |
Thanks for making the requested changes! @pablogsal: please review the changes made to this pull request. |
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
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.
Ah, this looks MUCH better. Really well done @sergey-miryanov! 👍
Misc/NEWS.d/next/Core_and_Builtins/2025-02-09-11-30-38.gh-issue-129515.3L3vmo.rst
Outdated
Show resolved
Hide resolved
…e-129515.3L3vmo.rst Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…y-miryanov/cpython into pythongh-129515-ifexp-syntax-error
Thank you all for your review! I made the suggested changes, and it is ready now. |
Excellent job @sergey-miryanov! Thanks for your contribution 👌 |
Thanks! |
Along the suggestion from the original issue, I have added the following rules and messages:
The following expressions will be handled by
a=disjunction 'if' b=disjunction 'else' c=invalid_ifexp_orelse_stmt
and generate the message "Syntax Error: statement given where 'orelse' expression required" instead of just "Syntax Error: invalid syntax":The following expressions will be handled by
a=invalid_ifexp_body_stmt 'if' b=disjunction 'else' c=expression
and generate the message "Syntax Error: statement given where 'body' expression required":The followingexpressions will be handled by
a=invalid_ifexp_body_stmt 'if' b=disjunction 'else' c=invalid_ifexp_orelse_stmt
and generate the message "Syntax Error: statement given where 'body' expression required":