mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
gh-98811: use full source location to simplify __future__ imports error checking. This also fixes an incorrect error offset. (GH-98812)
This commit is contained in:
parent
29f98b46b7
commit
39448adc9d
5 changed files with 71 additions and 69 deletions
|
@ -31,11 +31,26 @@ typedef struct {
|
|||
#define _PyCompilerFlags_INIT \
|
||||
(PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION}
|
||||
|
||||
/* source location information */
|
||||
typedef struct {
|
||||
int lineno;
|
||||
int end_lineno;
|
||||
int col_offset;
|
||||
int end_col_offset;
|
||||
} _PyCompilerSrcLocation;
|
||||
|
||||
#define SRC_LOCATION_FROM_AST(n) \
|
||||
(_PyCompilerSrcLocation){ \
|
||||
.lineno = (n)->lineno, \
|
||||
.end_lineno = (n)->end_lineno, \
|
||||
.col_offset = (n)->col_offset, \
|
||||
.end_col_offset = (n)->end_col_offset }
|
||||
|
||||
/* Future feature support */
|
||||
|
||||
typedef struct {
|
||||
int ff_features; /* flags set by future statements */
|
||||
int ff_lineno; /* line number of last future statement */
|
||||
int ff_features; /* flags set by future statements */
|
||||
_PyCompilerSrcLocation ff_location; /* location of last future statement */
|
||||
} PyFutureFeatures;
|
||||
|
||||
#define FUTURE_NESTED_SCOPES "nested_scopes"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue