mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #24528: Improve error message for awaits in comprehensions
This commit is contained in:
parent
4a01cab898
commit
9dec03571f
2 changed files with 14 additions and 1 deletions
|
@ -106,6 +106,16 @@ class AsyncBadSyntaxTest(unittest.TestCase):
|
|||
with self.assertRaisesRegex(SyntaxError, 'invalid syntax'):
|
||||
import test.badsyntax_async9
|
||||
|
||||
def test_badsyntax_10(self):
|
||||
ns = {}
|
||||
for comp in {'(await a for a in b)',
|
||||
'[await a for a in b]',
|
||||
'{await a for a in b}',
|
||||
'{await a: c for a in b}'}:
|
||||
|
||||
with self.assertRaisesRegex( SyntaxError, 'await.*in comprehen'):
|
||||
exec('async def f():\n\t{}'.format(comp), ns, ns)
|
||||
|
||||
|
||||
class TokenizerRegrTest(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue