From 14541040e8cf92f66971a234a1c5e7e60cb11c85 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 22 Jan 2018 11:18:17 +0100 Subject: canonicalize: fix some compat issues for AST module TODO check if this is OK --- canonicalize/astTools.py | 4 ++-- canonicalize/display.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/canonicalize/astTools.py b/canonicalize/astTools.py index f644316..e67d908 100644 --- a/canonicalize/astTools.py +++ b/canonicalize/astTools.py @@ -1,4 +1,4 @@ -import ast, copy, pickle +import ast, copy, pickle, types from .tools import log from .namesets import * from .display import printFunction @@ -713,7 +713,7 @@ def eventualType(a): else: # Not op return bool elif type(a) == ast.Lambda: - return function + return types.LambdaType elif type(a) == ast.IfExp: l = eventualType(a.body) r = eventualType(a.orelse) diff --git a/canonicalize/display.py b/canonicalize/display.py index 174304f..5b8aa72 100644 --- a/canonicalize/display.py +++ b/canonicalize/display.py @@ -185,7 +185,7 @@ def printFunction(a, indent=0): s += printFunction(a.operand, indent) + ")" elif t == ast.Lambda: s += "lambda " - s += printFunction(a.arguments, indent) + ": " + s += printFunction(a.args, indent) + ": " s += printFunction(a.body, indent) elif t == ast.IfExp: s += "(" + printFunction(a.body, indent) @@ -359,7 +359,7 @@ def printFunction(a, indent=0): if (len(a.args) > 0 or a.vararg != None or a.kwarg != None or len(a.kwonlyargs) > 0): s = s[:-2] elif t == ast.arg: - s += a.arg + s += a.arg.s if isinstance(a.arg, ast.Str) else a.arg if a.annotation != None: s += ": " + printFunction(a.annotation, indent) elif t == ast.keyword: @@ -567,4 +567,4 @@ def formatNode(node): elif t == list: return formatList(node, None) else: - return printFunction(node, 0) \ No newline at end of file + return printFunction(node, 0) -- cgit v1.2.1