mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
bpo-33363: raise SyntaxError for async for/with outside async functions (#6616)
This commit is contained in:
parent
078c4e3519
commit
e239650660
3 changed files with 25 additions and 1 deletions
|
@ -362,7 +362,22 @@ class AsyncBadSyntaxTest(unittest.TestCase):
|
|||
"""def foo():
|
||||
async def bar():
|
||||
pass\nawait a
|
||||
"""]
|
||||
""",
|
||||
"""def foo():
|
||||
async for i in arange(2):
|
||||
pass
|
||||
""",
|
||||
"""def foo():
|
||||
async with resource:
|
||||
pass
|
||||
""",
|
||||
"""async with resource:
|
||||
pass
|
||||
""",
|
||||
"""async for i in arange(2):
|
||||
pass
|
||||
""",
|
||||
]
|
||||
|
||||
for code in samples:
|
||||
with self.subTest(code=code), self.assertRaises(SyntaxError):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue