diff options
author | Brian Schubert <brianm.schubert@gmail.com> | 2024-10-29 23:57:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-29 23:57:59 (GMT) |
commit | 224c370a3680132997f1e43d20a3b4ca95a060ab (patch) | |
tree | 34fabd982364362ebf462c14aee621c42893ca8f /Python/future.c | |
parent | 9dfef4e5f4ac3c1ce494c48f2476a694c12d72a5 (diff) | |
download | cpython-224c370a3680132997f1e43d20a3b4ca95a060ab.zip cpython-224c370a3680132997f1e43d20a3b4ca95a060ab.tar.gz cpython-224c370a3680132997f1e43d20a3b4ca95a060ab.tar.bz2 |
gh-126139: Improve error message location for future statement with unknown feature (#126140)
Diffstat (limited to 'Python/future.c')
-rw-r--r-- | Python/future.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Python/future.c b/Python/future.c index 8aeb541..79b6c0c 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; } } |