Author: Raffael Tfirst <[email protected]>
Branch: py3.5-async
Changeset: r85567:744aee598f7a
Date: 2016-07-05 17:56 +0200
http://bitbucket.org/pypy/pypy/changeset/744aee598f7a/
Log: Change handle_power to handle_atom_expr (with await)
diff --git a/pypy/interpreter/astcompiler/astbuilder.py
b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -946,11 +946,18 @@
raise AssertionError("invalid factor node")
return ast.UnaryOp(op, expr, factor_node.get_lineno(),
factor_node.get_column())
- def handle_power(self, power_node):
- atom_expr = self.handle_atom(power_node.get_child(0))
- if power_node.num_children() == 1:
+ def handle_atom_expr(self, power_node):
+ start = 0
+ num_ch = power_node.num_children()
+ if power_node.get_child(0).type == tokens.AWAIT:
+ start = 1
+ atom_expr = self.handle_atom(power_node.get_child(start))
+ if num_ch == 1:
return atom_expr
- for i in range(1, power_node.num_children()):
+ if start and num_ch == 2:
+ return ast.Await(atom_expr, power_node.get_lineno(),
+ power_node.get_column())
+ for i in range(start+1, num_ch):
trailer = power_node.get_child(i)
if trailer.type != syms.trailer:
break
@@ -962,7 +969,11 @@
right = self.handle_expr(power_node.get_child(-1))
atom_expr = ast.BinOp(atom_expr, ast.Pow, right,
power_node.get_lineno(),
power_node.get_column())
- return atom_expr
+ if start:
+ return ast.Await(atom_expr, power_node.get_lineno(),
+ power_node.get_column())
+ else:
+ return atom_expr
def handle_slice(self, slice_node):
first_child = slice_node.get_child(0)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit