8000 gh-104482: Fix error handling bugs in ast.c by iritkatriel · Pull Request #104483 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104482: Fix error handling bugs in ast.c #104483

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

Merged
merged 11 commits into from
May 15, 2023
Prev Previous commit
Next Next commit
missed a few loops
  • Loading branch information
iritkatriel committed May 15, 2023
commit 43a9d47e3db9563a804a225873bd1f8bb3ce0732
9 changes: 3 additions & 6 deletions Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ static int
validate_comprehension(struct validator *state, asdl_comprehension_seq *gens)
{
assert(!PyErr_Occurred());
Py_ssize_t i;
if (!asdl_seq_LEN(gens)) {
PyErr_SetString(PyExc_ValueError, "comprehension with no generators");
return 0;
}
for (i = 0; i < asdl_seq_LEN(gens); i++) {
for (Py_ssize_t i = 0; i < asdl_seq_LEN(gens); i++) {
comprehension_ty comp = asdl_seq_GET(gens, i);
if (!validate_expr(state, comp->target, Store) ||
!validate_expr(state, comp->iter, Load) ||
Expand All @@ -86,8 +85,7 @@ static int
validate_keywords(struct validator *state, asdl_keyword_seq *keywords)
{
assert(!PyErr_Occurred());
Py_ssize_t i;
for (i = 0; i < asdl_seq_LEN(keywords); i++)
for (Py_ssize_t i = 0; i < asdl_seq_LEN(keywords); i++)
if (!validate_expr(state, (asdl_seq_GET(keywords, i))->value, Load))
return 0;
return 1;
Expand All @@ -97,8 +95,7 @@ static int
validate_args(struct validator *state, asdl_arg_seq *args)
{
assert(!PyErr_Occurred());
Py_ssize_t i;
for (i = 0; i < asdl_seq_LEN(args); i++) {
for (Py_ssize_t i = 0; i < asdl_seq_LEN(args); i++) {
arg_ty arg = asdl_seq_GET(args, i);
VALIDATE_POSITIONS(arg);
if (arg->annotation && !validate_expr(state, arg->annotation, Load))
Expand Down
0