ImageImage

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.

classification
Title: await is valid in non async functions if PyCF_ALLOW_TOP_LEVEL_AWAIT is set
Type: behavior Stage: resolved
Components: asyncio Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, asvetlov, miss-islington, pablogsal, yselivanov
Priority: normal Keywords: patch

Created on 2020-03-15 03:50 by pablogsal, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19010 merged pablogsal, 2020-03-15 03:59
PR 19011 merged miss-islington, 2020-03-15 04:29
Messages (4)
msg364216 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-03-15 03:50
If PyCF_ALLOW_TOP_LEVEL_AWAIT is set this code is valid:

def f():
   await foo

And this should raise a "SyntaxError: 'await' outside async function". The reason is that the PyCF_ALLOW_TOP_LEVEL_AWAIT is global in the compiler and affects everything without checking if the current code being compiled is actually in the TOP level or not.
msg364217 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-03-15 04:29
New changeset 90235810ec28ca954bbf4b61a5ae5df7a00db409 by Pablo Galindo in branch 'master':
bpo-39965: Correctly raise SyntaxError if await is used outside async functions when PyCF_ALLOW_TOP_LEVEL_AWAIT is set (GH-19010)
https://github.com/python/cpython/commit/90235810ec28ca954bbf4b61a5ae5df7a00db409
msg364218 - (view) Author: miss-islington (miss-islington) Date: 2020-03-15 04:46
New changeset f7e32fcbd65490c921e1836c2399827d14d0eb7b by Miss Islington (bot) in branch '3.8':
bpo-39965: Correctly raise SyntaxError if await is used outside async functions when PyCF_ALLOW_TOP_LEVEL_AWAIT is set (GH-19010)
https://github.com/python/cpython/commit/f7e32fcbd65490c921e1836c2399827d14d0eb7b
msg364221 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2020-03-15 06:00
Good catch & PR ;) Thanks
History
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84146
2020-03-15 06:00:32yselivanovsetmessages: + msg364221
2020-03-15 04:46:30miss-islingtonsetmessages: + msg364218
2020-03-15 04:30:29pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-03-15 04:29:49miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request18358
2020-03-15 04:29:39pablogsalsetmessages: + msg364217
2020-03-15 03:59:05pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request18356
2020-03-15 03:58:24BTaskayasetnosy: + BTaskaya
2020-03-15 03:50:53pablogsalcreate