gh-149122: Fix segfault in compiler when certain builtin functions are passed a coroutine as arg (#149138)

This commit is contained in:
Irit Katriel 2026-04-29 14:35:51 +01:00 committed by GitHub
parent 4a5d25c26c
commit 16f292ef4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 1 deletions

View file

@ -3959,6 +3959,12 @@ maybe_optimize_function_call(compiler *c, expr_ty e, jump_target_label end)
return 0;
}
expr_ty generator_exp = asdl_seq_GET(args, 0);
PySTEntryObject *generator_entry = _PySymtable_Lookup(SYMTABLE(c), (void *)generator_exp);
if (generator_entry->ste_coroutine) {
return 0;
}
location loc = LOC(func);
int optimized = 0;
@ -3998,7 +4004,6 @@ maybe_optimize_function_call(compiler *c, expr_ty e, jump_target_label end)
} else if (const_oparg == CONSTANT_BUILTIN_SET) {
ADDOP_I(c, loc, BUILD_SET, 0);
}
expr_ty generator_exp = asdl_seq_GET(args, 0);
VISIT(c, expr, generator_exp);
NEW_JUMP_TARGET_LABEL(c, loop);