[issue39562] Asynchronous comprehensions don't work in asyncio REPL

Matthias Bussonnier report at bugs.python.org
Mon Jul 6 11:05:55 EDT 2020


Matthias Bussonnier <bussonniermatthias at gmail.com> added the comment:

This make non-await list comprehension coroutine-code-objects as well: 

https://bugs.python.org/issue41218

    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  # this is now TRUE. 

This leads to weird things in Jupyter/IPython when we try to detect wether a block of code is, or os not async.

----------
nosy: +mbussonn

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


More information about the Python-bugs-list mailing list