I'm opening this issue to discuss something I've noticed in Parser/action_helpers.c. There are multiple places where functions are called and their result is not checked, meaning if they error, Python will continue to try and execute its logic even though it would only be reasonable to bail. I initially thought those call sites skipped the return code / null pointer checks because they were redundant (i.e. that there was some assumption that some function calls can never fail) but upon further scrutiny that seems to be the case for none of them.
To take one random example:
_set_seq_context does asdl_seq_SET(new_seq, i, _PyPegen_set_expr_context(p, e, ctx)); here
_PyPegen_set_expr_context calls one of many functions, e.g. _set_name_context here
_set_name_context calls into _PyAST_Name
- ... which may return
NULL in several cases
The other cases are similar.
I have a fix branch here which also serves as a list of all the places in this specific file that would be worth fixing.
Let me know what you think.
I'm opening this issue to discuss something I've noticed in
Parser/action_helpers.c. There are multiple places where functions are called and their result is not checked, meaning if they error, Python will continue to try and execute its logic even though it would only be reasonable to bail. I initially thought those call sites skipped the return code / null pointer checks because they were redundant (i.e. that there was some assumption that some function calls can never fail) but upon further scrutiny that seems to be the case for none of them.To take one random example:
_set_seq_contextdoesasdl_seq_SET(new_seq, i, _PyPegen_set_expr_context(p, e, ctx));here_PyPegen_set_expr_contextcalls one of many functions, e.g._set_name_contexthere_set_name_contextcalls into_PyAST_NameNULLin several casesThe other cases are similar.
I have a fix branch here which also serves as a list of all the places in this specific file that would be worth fixing.
Let me know what you think.