-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Initial problem starts here:
parser.add_argument(
'--dump',
type=bool,
help="Show a pretty-printed AST instead of the source"
)
It would rather be action="store_true".
Working that around and running as python3 -m astunparse test.py --dump=True, with a trivial test.py of print(1) leads to the exception below. Because a filename is passed to a function which actually expects an AST tree.
$ python3 -m astunparse test.py --dump=True
test.py
=======
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/pfalcon/projects-3rdparty/Python/Python-ast/astunparse/lib/astunparse/__main__.py", line 48, in <module>
main(sys.argv[1:])
File "/home/pfalcon/projects-3rdparty/Python/Python-ast/astunparse/lib/astunparse/__main__.py", line 44, in main
roundtrip_recursive(target, dump_tree=arguments.dump)
File "/home/pfalcon/projects-3rdparty/Python/Python-ast/astunparse/lib/astunparse/__main__.py", line 14, in roundtrip_recursive
dump(target)
File "/home/pfalcon/projects-3rdparty/Python/Python-ast/astunparse/lib/astunparse/__init__.py", line 19, in dump
Printer(file=v).visit(tree)
File "/home/pfalcon/projects-3rdparty/Python/Python-ast/astunparse/lib/astunparse/printer.py", line 16, in visit
super(Printer, self).visit(node)
File "/usr/lib/python3.6/ast.py", line 253, in visit
return visitor(node)
File "/home/pfalcon/projects-3rdparty/Python/Python-ast/astunparse/lib/astunparse/printer.py", line 30, in generic_visit
children = [(name + "=", value) for name, value in ast.iter_fields(node)]
File "/home/pfalcon/projects-3rdparty/Python/Python-ast/astunparse/lib/astunparse/printer.py", line 30, in <listcomp>
children = [(name + "=", value) for name, value in ast.iter_fields(node)]
File "/usr/lib/python3.6/ast.py", line 171, in iter_fields
for field in node._fields:
AttributeError: 'str' object has no attribute '_fields'
Metadata
Metadata
Assignees
Labels
No labels