Text of bugs.python.org › issue24528 as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Issue 24528: Misleading exeption for await in comprehensions. - Python tracker

Python Home About News Documentation Downloads Community Foundation Developer's Guide Issue Tracker Issues Search Random Issue Summaries Issues with patch Easy issues Stats User Administration User List Committer List Help Tracker Documentation Tracker Development Report Tracker Problem Issue24528 ➜ This issue tracker has been migrated to GitHub , and is currently read-only . For more information, see the GitHub FAQs in the Python's Developer Guide.

Created on 2015-06-29 11:28 by levkivskyi , last changed 2022-04-11 14:58 by admin . This issue is now closed . Files File name Uploaded Description Edit awaitcomp.patch yselivanov , 2015-06-29 16:29 review Messages (4) msg245931 - (view) Author: Ivan Levkivskyi (levkivskyi) * Date: 2015-06-29 11:28 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 msg245951 - (view) Author: Yury Selivanov (yselivanov) * Date: 2015-06-29 16:29 Thanks for discovering this, Ivan.

The patch is attached. msg245995 - (view) Author: Roundup Robot (python-dev) Date: 2015-06-30 16:49 New changeset 30b676e8b21f by Yury Selivanov in branch '3.5': Issue #24528 : Improve error message for awaits in comprehensions https://hg.python.org/cpython/rev/30b676e8b21f New changeset 9598bc916186 by Yury Selivanov in branch 'default': Merge 3.5 (Issue #24528 ) https://hg.python.org/cpython/rev/9598bc916186 msg246030 - (view) Author: Ivan Levkivskyi (levkivskyi) * Date: 2015-07-01 08:34 Yury, thank you for the patch, the error message is much clearer now.

History Date User Action Args 2022-04-11 14:58:18 admin set github: 68716 2015-07-01 08:34:38 levkivskyi set messages: + msg246030 2015-06-30 16:49:56 yselivanov set status: open -> closed resolution: fixed stage: patch review -> resolved 2015-06-30 16:49:26 python-dev set nosy: + python-dev messages: + msg245995 2015-06-29 16:29:18 yselivanov set files: + awaitcomp.patch nosy: + ncoghlan messages: + msg245951 keywords: + needs review , patch stage: patch review 2015-06-29 13:46:27 yselivanov set assignee: yselivanov 2015-06-29 11:28:43 levkivskyi create Supported by The Python Software Foundation , Powered by Roundup Copyright © 1990-2022, Python Software Foundation Legal Statements