hy
hy copied to clipboard
ast.parse expects not None filename
=> (import hy.compiler [asty])
=> (asty.parse '1 "1 + 1" "<string>" "eval")
<ast.Expression object at 0x7f124604c700>
=> (asty.parse '1 "1 + 1" None "eval")
Traceback (most recent call last):
File "stdin-dcc5fc697bf44164cb8034c9a58f5f1c670b51a6", line 1, in <module>
(asty.parse '1 "1 + 1" None "eval")
File "/usr/lib64/python3.10/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
TypeError: expected str, bytes or os.PathLike object, not NoneType
This hasn't been an issue before since, the lex methods defaulted to <string>
, but we have a couple places where filename
defaults to None
that have worked okay by chance. We should probably move those to default to <string>
to avoid unexpected future bugs.