Closed
Description
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:
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
- gh-126139: Improve error message location for future statement with unknown feature #126140
- [3.13] gh-126139: Improve error message location for future statement with unknown feature (GH-126140) #126155
- [3.12] gh-126139: Improve error message location for future statement with unknown feature (GH-126140) #126160