diff src/ast_convert.rs @ 72:7ac23f4336b1

Add ast.AsyncWith.
author Bastien Orivel <eijebong@bananium.fr>
date Mon, 13 Jun 2016 18:09:15 +0200
parents 2c1e2ce41263
children 2a6629ea82b5
line wrap: on
line diff
--- a/src/ast_convert.rs
+++ b/src/ast_convert.rs
@@ -544,6 +544,7 @@ fn parse_statement(py: Python, ast: PyOb
     let continue_type = ast_module.get(py, "Continue").unwrap();
     let assert_type = ast_module.get(py, "Assert").unwrap();
     let with_type = ast_module.get(py, "With").unwrap();
+    let async_with_type = ast_module.get(py, "AsyncWith").unwrap();
     let raise_type = ast_module.get(py, "Raise").unwrap();
     let try_type = ast_module.get(py, "Try").unwrap();
 
@@ -695,13 +696,13 @@ fn parse_statement(py: Python, ast: PyOb
         let msg = parse_optional_expr(py, msg);
 
         stmt::Assert(test, msg)
-    } else if is_instance(&ast, &with_type) {
+    } else if is_instance(&ast, &with_type) || is_instance(&ast, &async_with_type) {
         let items = ast.getattr(py, "items").unwrap();
         let body = ast.getattr(py, "body").unwrap();
 
         let items = parse_list(py, items, parse_withitem);
         let body = parse_list(py, body, parse_statement);
-        stmt::With(items, body)
+        stmt::With(items, body, is_instance(&ast, &async_with_type))
     } else if is_instance(&ast, &raise_type) {
         let exc = ast.getattr(py, "exc").unwrap();
         let cause = ast.getattr(py, "cause").unwrap();