Repository navigation
Asynchronous comprehensions don't work in asyncio REPL #83743
Copy link
Copy link
Closed
Labels
3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of liferelease-blockertopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = <Date 2020-07-06.20:18:05.903>
created_at = <Date 2020-02-05.17:28:25.689>
labels = ['type-bug', '3.8', '3.9', 'release-blocker', 'expert-asyncio']
title = "Asynchronous comprehensions don't work in asyncio REPL"
updated_at = <Date 2021-09-07.20:14:54.080>
user = 'https://github.com/jack1142'bugs.python.org fields:
activity = <Date 2021-09-07.20:14:54.080>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2020-07-06.20:18:05.903>
closer = 'pablogsal'
components = ['asyncio']
creation = <Date 2020-02-05.17:28:25.689>
creator = 'jack1142'
dependencies = []
files = []
hgrepos = []
issue_num = 39562
keywords = ['patch']
message_count = 28.0
messages = ['361443', '361445', '364600', '364601', '365311', '365312', '365313', '365347', '365881', '366838', '366841', '366843', '366849', '366851', '367015', '367018', '367734', '367847', '367855', '367890', '367892', '367897', '368334', '368835', '373131', '373159', '373168', '400234']
nosy_count = 10.0
nosy_names = ['asvetlov', 'lukasz.langa', 'serhiy.storchaka', 'mbussonn', 'Anthony Sottile', 'hroncok', 'pablogsal', 'miss-islington', 'BTaskaya', 'jack1142']
pr_nums = ['18968', '19010', '19070', '19230', '19835', '19838']
priority = 'release blocker'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue39562'
versions = ['Python 3.8', 'Python 3.9']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of liferelease-blockertopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
jack1142 commentedon Feb 5, 2020
asyncio REPL doesn't allow using asynchronous comprehensions outside of async func. Same behavior can also be observed when using
ast.PyCF_ALLOW_TOP_LEVEL_AWAITflag incompile()jack1142 commentedon Feb 5, 2020
I also noticed that putting
awaitbefore the async comprehension will make the code inside the comprehension run (though after it runs, it will fail on awaiting list):pablogsal commentedon Mar 19, 2020
New changeset 9052f7a by Batuhan Taşkaya in branch 'master':
bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL (GH-18968)
9052f7a
miss-islington commentedon Mar 19, 2020
New changeset ec8a973 by Miss Islington (bot) in branch '3.8':
bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL (GH-18968)
ec8a973
vstinner commentedon Mar 30, 2020
This change caused python-gmpy2 tests to fail:
https://bugzilla.redhat.com/show_bug.cgi?id=1817710
Reproducer:
---
====
>>> all(x == 1 for x in [1, 1, 1]) True """.strip(), file=fp)27 remaining items
Carreau commentedon Jul 6, 2020
This make non-await list comprehension coroutine-code-objects as well:
https://bugs.python.org/issue41218
This leads to weird things in Jupyter/IPython when we try to detect wether a block of code is, or os not async.
Carreau commentedon Jul 6, 2020
Pablo, I see you reopened and marked as blocker,
As the changes here has been released maybe you want to reclose and marked https://bugs.python.org/issue41218 as blocker it should also be fixed by
#21357
pablogsal commentedon Jul 6, 2020
Thanks for the heads up, Matthias!
Yes, I think is the best thing to do. For some reason, I thought this was not still released :(
asottile commentedon Aug 24, 2021
this maybe shouldn't have been backported to 3.8.x as the change in compiler flags appears to break pyc files in subtle ways: https://stackoverflow.com/q/68910329/812183