summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-09-09 17:36:01 (GMT)
committerYury Selivanov <yury@magic.io>2016-09-09 17:36:01 (GMT)
commit52c4e7cc84702750bb75d5423da01d01bcdfdf39 (patch)
tree01ebfe1725b4169baefa4e76aeaeffcd25153f3b /Lib/lib2to3
parent93b2dee80e5d72cf12522d773b512097493c09fc (diff)
downloadcpython-52c4e7cc84702750bb75d5423da01d01bcdfdf39.zip
cpython-52c4e7cc84702750bb75d5423da01d01bcdfdf39.tar.gz
cpython-52c4e7cc84702750bb75d5423da01d01bcdfdf39.tar.bz2
Issue #28008: Implement PEP 530 -- asynchronous comprehensions.
Diffstat (limited to 'Lib/lib2to3')
-rw-r--r--Lib/lib2to3/Grammar.txt2
-rw-r--r--Lib/lib2to3/tests/test_parser.py18
2 files changed, 19 insertions, 1 deletions
diff --git a/Lib/lib2to3/Grammar.txt b/Lib/lib2to3/Grammar.txt
index abe1268..dcdd02d 100644
--- a/Lib/lib2to3/Grammar.txt
+++ b/Lib/lib2to3/Grammar.txt
@@ -150,7 +150,7 @@ arglist: (argument ',')* (argument [',']
argument: test [comp_for] | test '=' test # Really [keyword '='] test
comp_iter: comp_for | comp_if
-comp_for: 'for' exprlist 'in' testlist_safe [comp_iter]
+comp_for: [ASYNC] 'for' exprlist 'in' testlist_safe [comp_iter]
comp_if: 'if' old_test [comp_iter]
testlist1: test (',' test)*
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py
index b378163..7613f53 100644
--- a/Lib/lib2to3/tests/test_parser.py
+++ b/Lib/lib2to3/tests/test_parser.py
@@ -134,6 +134,24 @@ class TestAsyncAwait(GrammarTest):
""")
self.validate("""async def foo():
+ [i async for i in b]
+ """)
+
+ self.validate("""async def foo():
+ {i for i in b
+ async for i in a if await i
+ for b in i}
+ """)
+
+ self.validate("""async def foo():
+ [await i for i in b if await c]
+ """)
+
+ self.validate("""async def foo():
+ [ i for i in b if c]
+ """)
+
+ self.validate("""async def foo():
def foo(): pass