summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-01-22 11:18:17 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-01-22 11:18:17 +0100
commit14541040e8cf92f66971a234a1c5e7e60cb11c85 (patch)
tree6b7f3f4d1bdea5d0d7f46712fa38f3e997c8f1e6
parent6a399bb24af8cb1c4f104de479525a8c27ef2bbf (diff)
canonicalize: fix some compat issues for AST module
TODO check if this is OK
-rw-r--r--canonicalize/astTools.py4
-rw-r--r--canonicalize/display.py6
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)