From 224c370a3680132997f1e43d20a3b4ca95a060ab Mon Sep 17 00:00:00 2001 From: Brian Schubert Date: Tue, 29 Oct 2024 19:57:59 -0400 Subject: gh-126139: Improve error message location for future statement with unknown feature (#126140) --- Python/future.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Python/future.c') diff --git a/Python/future.c b/Python/future.c index 8aeb541cb05..79b6c0c503b 100644 --- a/Python/future.c +++ b/Python/future.c @@ -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; } } -- cgit v1.2.3