[issue41218] PyCF_ALLOW_TOP_LEVEL_AWAIT + list comprehension set .CO_COROUTINE falg.

Matthias Bussonnier report at bugs.python.org
Mon Jul 6 11:00:52 EDT 2020


New submission from Matthias Bussonnier <bussonniermatthias at gmail.com>:

As far as I can tell sometime in 3.8.x (likely 3.8.3) the following snippet changed result:

    import ast
    import inspect
    cell = '[x for x in l]'
    code = compile(cell, "<>", "exec", flags=getattr(ast,'PyCF_ALLOW_TOP_LEVEL_AWAIT', 0x0))

    inspect.CO_COROUTINE & code.co_flags == inspect.CO_COROUTINE


Use to be False in 3.8.2 I believe and is False after.

This is problematic when you try to detect top-level await code.

----------
components: Interpreter Core
messages: 373128
nosy: mbussonn
priority: normal
severity: normal
status: open
title: PyCF_ALLOW_TOP_LEVEL_AWAIT + list comprehension set .CO_COROUTINE  falg.
versions: Python 3.10, Python 3.8, Python 3.9

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


More information about the Python-bugs-list mailing list