Content-Length: 307943 | pFad | https://github.com/python/cpython/issues/149689

ad Missing error / null pointer checks in `Parser/action_helpers.c` · Issue #149689 · python/cpython · GitHub
Skip to content

Missing error / null pointer checks in Parser/action_helpers.c #149689

Description

@KowalskiThomas

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.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertriagedThe issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/149689

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy