berkerpeksag / astor

Python AST read/write
https://pypi.org/project/astor/
BSD 3-Clause "New" or "Revised" License
810 stars 102 forks source link

Not rendering ** for PEP 448 Additional Unpacking Generalizations #83

Closed gilch closed 6 years ago

gilch commented 7 years ago

It looks like astor is not ready for some of the newer Python features.

Python 3.6.1

>>> import astor, ast
>>> astor.__version__
'0.5'
>>> compile("{1: 1, **{2: 2}}", "<str>", "exec", ast.PyCF_ONLY_AST)
<_ast.Module object at 0x00000180BB3F1F28>
>>> astor.codegen.to_source(_)
'{1: 1, None: {2: 2, }, }'

The stars are None:.

berkerpeksag commented 6 years ago

Thanks for the report. This is fixed in astor 0.6:

>>> import ast
>>> import astor
>>> compile("{1: 1, **{2: 2}}", "<str>", "exec", ast.PyCF_ONLY_AST)
<_ast.Module object at 0x7f0a3a080cf0>
>>> astor.to_source(_)
'{(1): 1, **{(2): 2}}\n'