berkerpeksag / astor

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

Invalid dumps of non-finite complex Nums #100

Closed Kodiologist closed 6 years ago

Kodiologist commented 6 years ago

Related to #82 and #85, ast.Nums containing non-finite complex numbers will be dumped as their reprs instead of legal Python expressions that evaluate to the right floating-point constructs.

import ast, astor

x = (1e1000 - 1e1000) - 1e1000j

print(x)
print(astor.code_gen.to_source(ast.Module([ast.Expr(ast.Num(x))])))

Both lines print as (nan-infj).