mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-126139: Improve error message location for future statement with unknown feature (#126140)
This commit is contained in:
parent
9dfef4e5f4
commit
224c370a36
4 changed files with 18 additions and 8 deletions
|
@ -41,12 +41,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