[New-bugs-announce] [issue41159] Nested async dict comprehension fails with SyntaxError
Hrvoje Nikšić
report at bugs.python.org
Mon Jun 29 10:50:41 EDT 2020
New submission from Hrvoje Nikšić <hniksic at gmail.com>:
Originally brought up on StackOverflow, https://stackoverflow.com/questions/60799366/nested-async-comprehension :
This dict comprehension parses and works correctly:
async def bar():
return {
n: await foo(n) for n in [1, 2, 3]
}
But making it nested fails with a SyntaxError:
async def bar():
return {
i: {
n: await foo(n) for n in [1, 2, 3]
} for i in [1,2,3]
}
The error reported is:
File "<stdin>", line 0
SyntaxError: asynchronous comprehension outside of an asynchronous function
----------
components: Interpreter Core
messages: 372582
nosy: hniksic
priority: normal
severity: normal
status: open
title: Nested async dict comprehension fails with SyntaxError
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41159>
_______________________________________
More information about the New-bugs-announce
mailing list