summaryrefslogtreecommitdiff
path: root/Lib/compiler/transformer.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/compiler/transformer.py')
-rw-r--r--Lib/compiler/transformer.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index 3607af11cb..c2a3b9648f 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -42,8 +42,14 @@ def parseFile(path):
f.close()
return parse(src)
-def parse(buf):
- return Transformer().parsesuite(buf)
+def parse(buf, mode="exec"):
+ if mode == "exec" or mode == "single":
+ return Transformer().parsesuite(buf)
+ elif mode == "eval":
+ return Transformer().parseexpr(buf)
+ else:
+ raise ValueError("compile() arg 3 must be"
+ " 'exec' or 'eval' or 'single'")
def asList(nodes):
l = []