Skip to content

Should we set default lineno on hand crafted ASTs? #130241

@iritkatriel

Description

@iritkatriel
>>> compile(ast.Module([ast.Expr(ast.Constant(value=(1,)))]), "", "exec")
Traceback (most recent call last):
  File "<python-input-39>", line 1, in <module>
    compile(ast.Module([ast.Expr(ast.Constant(value=(1,)))]), "", "exec")
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: required field "lineno" missing from stmt

The error is coming from the conversion of the AST to a C ast. Should we make the lineno default to something like, say, 1?
Or are we happy with this being an invalid AST?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions