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 error for indentation errors #88025

Closed
pablogsal opened this issue Apr 16, 2021 · 2 comments
Closed

Improve syntax error for indentation errors #88025

pablogsal opened this issue Apr 16, 2021 · 2 comments

Comments

@pablogsal
Copy link
Member

BPO 43859
Nosy @aroberge, @ammaraskar, @pablogsal
PRs
  • bpo-43859: Improve the error message for IndentationError exceptions #25431
  • 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-21.14:32:46.606>
    created_at = <Date 2021-04-16.00:26:09.825>
    labels = []
    title = 'Improve syntax error for indentation errors'
    updated_at = <Date 2021-04-21.14:32:46.605>
    user = 'https://github.com/pablogsal'

    bugs.python.org fields:

    activity = <Date 2021-04-21.14:32:46.605>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-04-21.14:32:46.606>
    closer = 'pablogsal'
    components = []
    creation = <Date 2021-04-16.00:26:09.825>
    creator = 'pablogsal'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43859
    keywords = ['patch']
    message_count = 2.0
    messages = ['391160', '391523']
    nosy_count = 3.0
    nosy_names = ['aroberge', 'ammar2', 'pablogsal']
    pr_nums = ['25431']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue43859'
    versions = []

    @pablogsal
    Copy link
    Member Author

    The current indentation error is quite simplistic and it does not include the context of the statement that was associated with the indented block and where it was:

    >>> def foo():
    ...     if lel:
    ...     x = 2
      File "<stdin>", line 3
        x = 2
        ^
    IndentationError: expected an indented block

    we can improve the error by adding some context:

    >>> def foo():
    ...    if lel:
    ...    x = 2
      File "<stdin>", line 3
        x = 2
        ^
    IndentationError: expected an indented block after if statement in line 2

    @pablogsal
    Copy link
    Member Author

    New changeset 56c95df by Pablo Galindo in branch 'master':
    bpo-43859: Improve the error message for IndentationError exceptions (GH-25431)
    56c95df

    @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