[New-bugs-announce] [issue39965] await is valid in non async functions if PyCF_ALLOW_TOP_LEVEL_AWAIT is set

Pablo Galindo Salgado report at bugs.python.org
Sat Mar 14 23:50:53 EDT 2020


New submission from Pablo Galindo Salgado <pablogsal at gmail.com>:

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.

----------
components: asyncio
messages: 364216
nosy: asvetlov, pablogsal, yselivanov
priority: normal
severity: normal
status: open
title: await is valid in non async functions if PyCF_ALLOW_TOP_LEVEL_AWAIT is set
type: behavior
versions: Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39965>
_______________________________________


More information about the New-bugs-announce mailing list