[issue24528] Misleading exeption for await in comprehensions.
Ivan Levkivskyi
report at bugs.python.org
Mon Jun 29 13:28:43 CEST 2015
New submission from Ivan Levkivskyi:
The following code:
async def foo():
lst = [await coro(i) for i in range(10)]
return lst
gives
SyntaxError: 'await' outside async function
I understand that this is because the comprehensions are implemented using a function scope (see also #10544), but such behavior is unintuitive.
IMO there are two possibilities here:
1) make comprehensions behave more like a for loop;
2) change the exception text to something like "SyntaxError: 'await's in comprehensions are not supported".
I understand that the first option is probably not for 3.5 (it is beta already), but I will be happy if the second option will be implemented in 3.5
----------
components: Interpreter Core, asyncio
messages: 245931
nosy: gvanrossum, haypo, levkivskyi, yselivanov
priority: normal
severity: normal
status: open
title: Misleading exeption for await in comprehensions.
type: behavior
versions: Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24528>
_______________________________________
More information about the Python-bugs-list
mailing list