FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-129515: Clarify syntax error messages for conditional expressions by sergey-miryanov · Pull Request #129880 · python/cpython · GitHub

/ cpython Public

gh-129515: Clarify syntax error messages for conditional expressions - #129880

Merged
pablogsal merged 24 commits into
python:mainfrom
sergey-miryanov:gh-129515-ifexp-syntax-error
Feb 18, 2025
Merged

gh-129515: Clarify syntax error messages for conditional expressions#129880
pablogsal merged 24 commits into
python:mainfrom
sergey-miryanov:gh-129515-ifexp-syntax-error

Conversation

sergey-miryanov commented Feb 9, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

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":

1 if True else pass
1 if True else return
1 if True else raise Exception('test')
1 if True else del smth
1 if True else yield 2
1 if True else assert False
1 if True else break
1 if True else continue

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":

pass if True else 1
break if True else 1
continue if True else 1

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":

pass if True else pass
break if True else continue

Comment thread Grammar/python.gram Outdated
Comment thread Grammar/python.gram Outdated
Comment thread Grammar/python.gram Outdated
sergey-miryanov marked this pull request as draft February 9, 2025 06:55

Copy link
Copy Markdown
Contributor Author

test_fstring fails, will dig

Comment thread Grammar/python.gram Outdated
Comment thread Grammar/python.gram Outdated
Comment thread Grammar/python.gram Outdated
Comment thread Grammar/python.gram Outdated
sergey-miryanov marked this pull request as ready for review February 9, 2025 09:25
Comment thread Lib/test/test_ast/test_ast.py Outdated
sergey-miryanov marked this pull request as draft February 10, 2025 18:35
sergey-miryanov marked this pull request as ready for review February 10, 2025 18:38

pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Left some new comments

bedevere-app Bot commented Feb 12, 2025

Copy link
Copy Markdown

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

bedevere-app Bot commented Feb 13, 2025

Copy link
Copy Markdown

Thanks for making the requested changes!

@pablogsal: please review the changes made to this pull request.

bedevere-app Bot requested a review from pablogsal February 13, 2025 19:43
Comment thread Doc/whatsnew/3.14.rst Outdated
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ah, this looks MUCH better. Really well done @sergey-miryanov! 👍

Comment thread Grammar/python.gram
Comment thread Doc/whatsnew/3.14.rst Outdated
Comment thread Lib/test/test_syntax.py
sergey-miryanov and others added 3 commits February 17, 2025 18:25
…e-129515.3L3vmo.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

Copy link
Copy Markdown
Contributor Author

Thank you all for your review! I made the suggested changes, and it is ready now.

pablogsal merged commit bcc9a5d into python:main Feb 18, 2025

Copy link
Copy Markdown
Member

Excellent job @sergey-miryanov!

Thanks for your contribution 👌

Copy link
Copy Markdown
Contributor Author

Thanks!

sergey-miryanov deleted the gh-129515-ifexp-syntax-error branch February 19, 2025 12:43
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL