From 0a5bc21fcf2c0653b3a6460b57d9a0d04c74ae5e Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Fri, 18 May 2018 10:29:01 -0700 Subject: [PATCH] Simplify compile_numeric_literal for new astor --- hy/compiler.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index b4fbda6..e69fe9b 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -1670,23 +1670,7 @@ class HyASTCompiler(object): f = {HyInteger: long_type, HyFloat: float, HyComplex: complex}[type(x)] - # Work around https://github.com/berkerpeksag/astor/issues/85 : - # astor can't generate Num nodes with NaN, so we have - # to build an expression that evaluates to NaN. - def nn(number): - return asty.Num(x, n=number) - if isnan(x): - def nan(): return asty.BinOp( - x, left=nn(1e900), op=ast.Sub(), right=nn(1e900)) - if f is complex: - return asty.Call( - x, - func=asty.Name(x, id="complex", ctx=ast.Load()), - keywords=[], - args=[nan() if isnan(x.real) else nn(x.real), - nan() if isnan(x.imag) else nn(x.imag)]) - return nan() - return nn(f(x)) + return asty.Num(x, n=f(x)) @builds_model(HySymbol) def compile_symbol(self, symbol):