diff options
| author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-10-31 13:08:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-31 13:08:03 +0000 |
| commit | 39448adc9db0c0444443a42f13a9d7e1441b88e8 (patch) | |
| tree | 6b311cc323760f1231550babdb525e1c6feafef6 /Include/cpython | |
| parent | 29f98b46b77ee528477b9a7b335974b9682f7f14 (diff) | |
| download | cpython-git-39448adc9db0c0444443a42f13a9d7e1441b88e8.tar.gz | |
gh-98811: use full source location to simplify __future__ imports error checking. This also fixes an incorrect error offset. (GH-98812)
Diffstat (limited to 'Include/cpython')
| -rw-r--r-- | Include/cpython/compile.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Include/cpython/compile.h b/Include/cpython/compile.h index 518a376499..f5a62a8ec6 100644 --- a/Include/cpython/compile.h +++ b/Include/cpython/compile.h @@ -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" |
