[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:
Brian Schubert 2024-10-29 20:54:32 -04:00 committed by GitHub
parent 7812dc37ab
commit e5c7543f12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 7 deletions

View file

@ -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;
}
}