Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-92597: Improve error message for AST nodes with invalid ranges #93398

Merged
merged 2 commits into from
Jun 1, 2022

Conversation

pablogsal
Copy link
Member

No description provided.

Copy link
Member

@isidentical isidentical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (a quick comment below)

Python/ast.c Outdated
node->lineno, node->end_lineno); \
return 0; \
} \
if ((node->lineno < 0 && node->end_lineno != node->lineno) || \
(node->col_offset < 0 && node->col_offset != node->end_col_offset)) { \
PyErr_Format(PyExc_ValueError, \
"line %d-%d, column %d-%d is not a valid range", \
node->lineno, node->end_lineno, node->col_offset, node->end_col_offset); \
"AST node column range (%d, %d) for line %d is not valid", \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to include the end_lineno here as well (since it is part of the original condition):

    if ((node->lineno < 0 && node->end_lineno != node->lineno) || \

Python/ast.c Outdated Show resolved Hide resolved
@pablogsal pablogsal merged commit 8a221a8 into python:main Jun 1, 2022
@pablogsal pablogsal deleted the ast_error branch June 1, 2022 12:51
@miss-islington
Copy link
Contributor

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-93414 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jun 1, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 1, 2022
…es (pythonGH-93398)

(cherry picked from commit 8a221a8)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
pablogsal added a commit that referenced this pull request Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants