Skip to content
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

Improve syntax errors for invalid if expressions #88955

Closed
miguendes mannequin opened this issue Jul 31, 2021 · 3 comments
Closed

Improve syntax errors for invalid if expressions #88955

miguendes mannequin opened this issue Jul 31, 2021 · 3 comments

Comments

@miguendes
Copy link
Mannequin

miguendes mannequin commented Jul 31, 2021

BPO 44792
Nosy @aroberge, @pablogsal, @miss-islington, @miguendes
PRs
  • bpo-44792: Improve syntax errors for if expressions #27506
  • [3.10] bpo-44792: Improve syntax errors for if expressions (GH-27506) #27565
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-08-02.19:05:42.925>
    created_at = <Date 2021-07-31.11:25:20.977>
    labels = []
    title = 'Improve syntax errors for invalid if expressions'
    updated_at = <Date 2021-08-02.19:05:43.048>
    user = 'https://github.com/miguendes'

    bugs.python.org fields:

    activity = <Date 2021-08-02.19:05:43.048>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-08-02.19:05:42.925>
    closer = 'pablogsal'
    components = []
    creation = <Date 2021-07-31.11:25:20.977>
    creator = 'miguendes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44792
    keywords = ['patch']
    message_count = 3.0
    messages = ['398633', '398787', '398799']
    nosy_count = 4.0
    nosy_names = ['aroberge', 'pablogsal', 'miss-islington', 'miguendes']
    pr_nums = ['27506', '27565']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44792'
    versions = []

    @miguendes
    Copy link
    Mannequin Author

    miguendes mannequin commented Jul 31, 2021

    Hi, I was playing around with Python's grammar and noticed that the error message for if expression is generic, so not very informative.

    I decided to improve it slightly.

    *From*:

    >>> a = 42 if True
      File "<stdin>", line 1
        a = 42 if True
                      ^
    SyntaxError: invalid syntax
    

    *To*:

    $ ./python
    Python 3.10.0b4 (tags/v3.10.0b4-dirty:2ba4b20854, Jul 31 2021, 11:50:15) [GCC 7.5.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> a = 42 if True
      File "<stdin>", line 1
        a = 42 if True
                      ^
    SyntaxError: invalid syntax. Conditional expression expected an 'else' here.
    

    @pablogsal
    Copy link
    Member

    New changeset 28b6dc9 by Miguel Brito in branch 'main':
    bpo-44792: Improve syntax errors for if expressions (GH-27506)
    28b6dc9

    @pablogsal
    Copy link
    Member

    New changeset 5671762 by Miss Islington (bot) in branch '3.10':
    bpo-44792: Improve syntax errors for if expressions (GH-27506) (GH-27565)
    5671762

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    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

    No branches or pull requests

    1 participant