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 dictionary literals #87989

Closed
pablogsal opened this issue Apr 13, 2021 · 3 comments
Closed

Improve syntax errors for invalid dictionary literals #87989

pablogsal opened this issue Apr 13, 2021 · 3 comments

Comments

@pablogsal
Copy link
Member

@pablogsal pablogsal commented Apr 13, 2021

BPO 43823
Nosy @pablogsal
PRs
  • #25378
  • #25427
  • 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-04-15.13:07:07.933>
    created_at = <Date 2021-04-13.02:05:47.571>
    labels = []
    title = 'Improve syntax errors for invalid dictionary literals'
    updated_at = <Date 2021-04-15.23:45:51.371>
    user = 'https://github.com/pablogsal'

    bugs.python.org fields:

    activity = <Date 2021-04-15.23:45:51.371>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-04-15.13:07:07.933>
    closer = 'pablogsal'
    components = []
    creation = <Date 2021-04-13.02:05:47.571>
    creator = 'pablogsal'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43823
    keywords = ['patch']
    message_count = 3.0
    messages = ['390917', '391135', '391155']
    nosy_count = 1.0
    nosy_names = ['pablogsal']
    pr_nums = ['25378', '25427']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue43823'
    versions = []

    @pablogsal
    Copy link
    Member Author

    @pablogsal pablogsal commented Apr 13, 2021

    Currently the error for invalid dict literals is generic:

    >>> {1:2, 3:}
      File "<stdin>", line 1
        {1:2, 3:}
                ^
    SyntaxError: invalid syntax
    >>> {1:2, 3}
      File "<stdin>", line 1
        {1:2, 3}
               ^
    SyntaxError: invalid syntax

    We can have better errors for these cases, which can help with big dict literals:

    >>> {1:2, 3}
      File "<stdin>", line 1
        {1:2, 3}
               ^
    SyntaxError: ':' expected after dictionary key
    >>> {1:2, 3:}
      File "<stdin>", line 1
        {1:2, 3:}
               ^
    SyntaxError: expression expected after dictionary key and ':'

    @pablogsal
    Copy link
    Member Author

    @pablogsal pablogsal commented Apr 15, 2021

    New changeset da74350 by Pablo Galindo in branch 'master':
    bpo-43823: Improve syntax errors for invalid dictionary literals (GH-25378)
    da74350

    @pablogsal
    Copy link
    Member Author

    @pablogsal pablogsal commented Apr 15, 2021

    New changeset b5b98bd by Pablo Galindo in branch 'master':
    bpo-43823: Fix location of one of the errors for invalid dictionary literals (GH-25427)
    b5b98bd

    @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