GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-129515: Clarify syntax error messages for conditional expressions by sergey-miryanov · Pull Request #129880 · python/cpython

Conversation

@sergey-miryanov

@sergey-miryanov sergey-miryanov commented Feb 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Syntax error on '{z} if z is not None else pass' #129515

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sergey-miryanov
pythongh-129515: Clarify syntax error messages for conditional expres…
4dbba6b
…sions
@sergey-miryanov
sergey-miryanov requested review from Eclips4, lysnikolaou and pablogsal as code owners February 9, 2025 06:14
@bedevere-app bedevere-app Bot added the awaiting review label Feb 9, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Feb 9, 2025
Syntax error on '{z} if z is not None else pass' #129515
Closed
sergey-miryanov
sergey-miryanov commented Feb 9, 2025
View reviewed changes
Comment thread Grammar/python.gram Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov commented Feb 9, 2025
View reviewed changes
Comment thread Grammar/python.gram Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov commented Feb 9, 2025
View reviewed changes
Comment thread Grammar/python.gram Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sergey-miryanov
Update news
6686090
@sergey-miryanov
sergey-miryanov marked this pull request as draft February 9, 2025 06:55
@bedevere-app bedevere-app Bot removed the awaiting review label Feb 9, 2025
@sergey-miryanov

sergey-miryanov commented Feb 9, 2025

Copy link
Copy Markdown
Contributor Author

test_fstring fails, will dig

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sergey-miryanov
Replace simple_stmt_without_expressions with explicit invalid_ifexp_*
b204fdb
sergey-miryanov
sergey-miryanov commented Feb 9, 2025
View reviewed changes
Comment thread Grammar/python.gram Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov commented Feb 9, 2025
View reviewed changes
Comment thread Grammar/python.gram Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov commented Feb 9, 2025
View reviewed changes
Comment thread Grammar/python.gram Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov
sergey-miryanov commented Feb 9, 2025
View reviewed changes
Comment thread Grammar/python.gram Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sergey-miryanov
Merge branch 'main' into pythongh-129515-ifexp-syntax-error
aa3f17d
@sergey-miryanov
sergey-miryanov marked this pull request as ready for review February 9, 2025 09:25
@bedevere-app bedevere-app Bot added the awaiting review label Feb 9, 2025
@sergey-miryanov
elif after else
8acc305
picnixz
picnixz reviewed Feb 10, 2025
View reviewed changes
Comment thread Lib/test/test_ast/test_ast.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov added 3 commits February 10, 2025 23:11
@sergey-miryanov
Merge branch 'pythongh-129515-ifexp-syntax-error' of github.com:serge…
b43b3a2
…y-miryanov/cpython into pythongh-129515-ifexp-syntax-error
@sergey-miryanov
Merge branch 'main' into pythongh-129515-ifexp-syntax-error
48e4796
@sergey-miryanov
Simplify test_ifexp_* tests
60c5066
@sergey-miryanov
sergey-miryanov marked this pull request as draft February 10, 2025 18:35
@bedevere-app bedevere-app Bot removed the awaiting review label Feb 10, 2025
@sergey-miryanov
Remove an accidentally added test line
c33b08f
@sergey-miryanov
sergey-miryanov marked this pull request as ready for review February 10, 2025 18:38
pablogsal
pablogsal requested changes Feb 12, 2025
View reviewed changes

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting change review labels Feb 12, 2025
@bedevere-app

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov added 2 commits February 13, 2025 20:47
@sergey-miryanov
Merge branch 'main' into pythongh-129515-ifexp-syntax-error
63b4400
@sergey-miryanov
Fix invalid rule for ifexp if statement given after else
903d9b6
- also reword error messages
- move tests to test_syntax
- update whatsnew and news
@sergey-miryanov

sergey-miryanov commented Feb 13, 2025

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Feb 13, 2025
@bedevere-app

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from pablogsal February 13, 2025 19:43
@sergey-miryanov
Update doc-string in test_syntax
b1c0ab4
StanFromIreland
StanFromIreland reviewed Feb 16, 2025
View reviewed changes
Comment thread Doc/whatsnew/3.14.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sergey-miryanov @StanFromIreland
Update Doc/whatsnew/3.14.rst
a33a705
Co-authored-by: Stan Ulbrych <[email protected]>
pablogsal
pablogsal approved these changes Feb 16, 2025
View reviewed changes

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

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! 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels Feb 16, 2025
pablogsal
pablogsal reviewed Feb 16, 2025
View reviewed changes
Comment thread Grammar/python.gram Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Feb 17, 2025
View reviewed changes
Comment thread Doc/whatsnew/3.14.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_syntax.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Feb 17, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2025-02-09-11-30-38.gh-issue-129515.3L3vmo.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

sergey-miryanov and others added 3 commits February 17, 2025 18:25
@sergey-miryanov @picnixz
Update Misc/NEWS.d/next/Core_and_Builtins/2025-02-09-11-30-38.gh-issu…
9c711ae
…e-129515.3L3vmo.rst

Co-authored-by: Bénédikt Tran <[email protected]>
@sergey-miryanov
Update tests and whatsnew entry
b4a1c55
@sergey-miryanov
Merge branch 'pythongh-129515-ifexp-syntax-error' of github.com:serge…
c468622
…y-miryanov/cpython into pythongh-129515-ifexp-syntax-error
@sergey-miryanov

sergey-miryanov commented Feb 17, 2025

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal
pablogsal approved these changes Feb 18, 2025
View reviewed changes
@pablogsal
pablogsal merged commit bcc9a5d into python:main Feb 18, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 18, 2025
@pablogsal

pablogsal commented Feb 18, 2025

Copy link
Copy Markdown
Member

Excellent job @sergey-miryanov!

Thanks for your contribution 👌

sergey-miryanov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sergey-miryanov

sergey-miryanov commented Feb 19, 2025

Copy link
Copy Markdown
Contributor Author

Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@picnixz picnixz picnixz left review comments
@StanFromIreland StanFromIreland StanFromIreland left review comments
@pablogsal pablogsal pablogsal approved these changes
@Eclips4 Eclips4 Awaiting requested review from Eclips4
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@sergey-miryanov @picnixz @ZeroIntensity @pablogsal @StanFromIreland
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.