Skip to content

Improve error message locations for future statements with unknown future features #126139

Closed

Description

@brianschubert

Feature or enhancement

Proposal:

Currently, attempting to use a future statement with an unknown future feature produces a syntax error with the error location set to the start of the line:

$ python3 example.py
  File "../example.py", line 1
    from __future__ import does_not_exist
    ^
SyntaxError: future feature does_not_exist is not defined

This has some unfortunate UX in the new 3.13 REPL, where it results in only the f character at the start of the line being highlighted:

image

The UX is also suboptimal for future statements with multiple future features, since the error location doesn't show which feature is causing the error:

$ python3 example.py
  File "../example.py", line 1
    from __future__ import division, with_statement, pirnt_function
    ^
SyntaxError: future feature pirnt_function is not defined

It would be nice if the error location instead highlighted the specific future feature that isn't defined. Something like:

$ python3 example.py
  File "../example.py", line 1
    from __future__ import division, with_statement, pirnt_function
                                                     ^^^^^^^^^^^^^^
SyntaxError: future feature pirnt_function is not defined

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added a commit that references this issue on Oct 29, 2024
  2. added a commit that references this issue on Oct 29, 2024
  3. added a commit that references this issue on Oct 29, 2024
  4. added 3 commits that reference this issue on Oct 30, 2024
  5. added 2 commits that reference this issue on Oct 30, 2024
  6. added a commit that references this issue on Dec 8, 2024
  7. added a commit that references this issue on Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions