Author: Raffael Tfirst <[email protected]>
Branch: py3.5-async
Changeset: r85576:9a227fcddc2e
Date: 2016-07-06 17:22 +0200
http://bitbucket.org/pypy/pypy/changeset/9a227fcddc2e/

Log:    Include is_async check in second handle_with_stmt function, return
        async and await tokens in tokenizer

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
@@ -447,11 +447,16 @@
             target = None
         return ast.withitem(test, target)
 
-    def handle_with_stmt(self, with_node):
+    def handle_with_stmt(self, with_node, is_async):
         body = self.handle_suite(with_node.get_child(-1))
         items = [self.handle_with_item(with_node.get_child(i))
                  for i in range(1, with_node.num_children()-2, 2)]
-        return ast.With(items, body, with_node.get_lineno(), 
with_node.get_column())
+        if is_async:
+            return ast.AsyncWith(items, body, with_node.get_lineno(),
+                                 with_node.get_column())
+        else:
+            return ast.With(items, body, with_node.get_lineno(),
+                            with_node.get_column())
 
     def handle_classdef(self, classdef_node, decorators=None):
         name_node = classdef_node.get_child(1)
@@ -502,10 +507,10 @@
                                    funcdef_node.get_lineno(), 
funcdef_node.get_column())
 
     def handle_async_funcdef(self, node, decorators=None):
-        return handle_funcdef_impl(node.get_child(1), 1, decorators)
+        return self.handle_funcdef_impl(node.get_child(1), 1, decorators)
     
     def handle_funcdef(self, node, decorators=None):
-        return handle_funcdef_impl(node, 0, decorators)
+        return self.handle_funcdef_impl(node, 0, decorators)
     
     def handle_async_stmt(self, node):
         ch = node.get_child(1)
diff --git a/pypy/interpreter/pyparser/pytokenizer.py 
b/pypy/interpreter/pyparser/pytokenizer.py
--- a/pypy/interpreter/pyparser/pytokenizer.py
+++ b/pypy/interpreter/pyparser/pytokenizer.py
@@ -253,7 +253,12 @@
                     if not verify_identifier(token):
                         raise TokenError("invalid character in identifier",
                                          line, lnum, start + 1, token_list)
-                    token_list.append((tokens.NAME, token, lnum, start, line))
+                    if token == "async":
+                        token_list.append((tokens.ASYNC, token, lnum, start, 
line))
+                    elif token == "await":
+                        token_list.append((tokens.AWAIT, token, lnum, start, 
line))
+                    else:
+                        token_list.append((tokens.NAME, token, lnum, start, 
line))
                     last_comment = ''
                 elif initial == '\\':                      # continued stmt
                     continued = 1
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to