__futures__ parsing can be simplified using complete source locations for error detection. Also the error's offset is off by one sometimes. #98811
Labels
3.12
only security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-bug
An unexpected behavior, bug, or error
type-feature
A feature request or enhancement
Uh oh!
There was an error while loading. Please reload this page.
The check for whether there are
__future__
imports which are not in the beginning of the script appears in two places:in future.c, future_parse, the ff_lineno is stored (last lineno of a
__future__
import) and there is a check for bad__future__
imports on the same line .Then in compile.c, compiler_from_import(), any import from
__future__
which is in a line afterc->c_future->ff_lineno
is rejected.If we replace ff_lineno by ff_location (the complete location information) then the check in compile.c can use the column info to detect the same-line case, and we no longer need to check for this in future.c. The code of future_parse will become much simpler.
There is also a bug in the future.c exception - the offset is off by 1, and this results in incorrect hilighting of the bad import:
My patch will result in this output instead:
The text was updated successfully, but these errors were encountered: