mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
[3.12] gh-126139: Improve error message location for future statement with unknown feature (GH-126140) (#126160)
(cherry picked from commit 224c370a36
)
This commit is contained in:
parent
7812dc37ab
commit
e5c7543f12
4 changed files with 17 additions and 7 deletions
|
@ -39,12 +39,20 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, PyObject *filename)
|
|||
} else if (strcmp(feature, "braces") == 0) {
|
||||
PyErr_SetString(PyExc_SyntaxError,
|
||||
"not a chance");
|
||||
PyErr_SyntaxLocationObject(filename, s->lineno, s->col_offset + 1);
|
||||
PyErr_RangedSyntaxLocationObject(filename,
|
||||
name->lineno,
|
||||
name->col_offset + 1,
|
||||
name->end_lineno,
|
||||
name->end_col_offset + 1);
|
||||
return 0;
|
||||
} else {
|
||||
PyErr_Format(PyExc_SyntaxError,
|
||||
UNDEFINED_FUTURE_FEATURE, feature);
|
||||
PyErr_SyntaxLocationObject(filename, s->lineno, s->col_offset + 1);
|
||||
PyErr_RangedSyntaxLocationObject(filename,
|
||||
name->lineno,
|
||||
name->col_offset + 1,
|
||||
name->end_lineno,
|
||||
name->end_col_offset + 1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue