FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL by isidentical · Pull Request #18968 · python/cpython · GitHub

/ cpython Public

bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL - #18968

Merged
pablogsal merged 5 commits into
python:masterfrom
isidentical:bpo-39562
Mar 19, 2020
Merged

bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL#18968
pablogsal merged 5 commits into
python:masterfrom
isidentical:bpo-39562

Conversation

isidentical commented Mar 12, 2020
edited by pablogsal
Loading

Copy link
Copy Markdown
Member

https://bugs.python.org/issue39562

Allow executing asynchronous comprehensions on the top level when the
PyCF_ALLOW_TOP_LEVEL_AWAIT flag is given.

Jackenmen commented Mar 12, 2020
edited
Loading

Copy link
Copy Markdown
Contributor

Does this also fix the async comprehension with await that was mentioned in the issue?
e.g.

[await asyncio.sleep(1, x) for x in range(5)]

I just noticed there's no test added for that and I don't know if these two cases differ under the hood.

Copy link
Copy Markdown
Member Author

Yes, it is! Will add a test.

>>> import asyncio
>>> [await asyncio.sleep(1, x) for x in range(5)]
[0, 1, 2, 3, 4]

Copy link
Copy Markdown
Contributor

Thanks for checking that :)

isidentical requested review from 1st1 and pablogsal March 12, 2020 19:50

Copy link
Copy Markdown
Member Author

I'm not sure if this is an enhancement or a bugfix so should we backports this to the 3.8? @1st1 @pablogsal

Copy link
Copy Markdown
Member

I think is a bug, this should be allowed the same way regular for loops are allowed so we need to backport this.

Comment thread Lib/test/test_builtin.py Outdated
Comment thread Python/compile.c Outdated
pablogsal changed the title bpo-39562: Run asynchronous comprehensions under asyncio repl bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL Mar 15, 2020
pablogsal self-assigned this Mar 15, 2020
pablogsal merged commit 9052f7a into python:master Mar 19, 2020

Copy link
Copy Markdown
Contributor

Thanks @isidentical for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 19, 2020
… REPL (pythonGH-18968)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
(cherry picked from commit 9052f7a)

Co-authored-by: Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com>

Copy link
Copy Markdown

GH-19070 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Mar 19, 2020
… REPL (GH-18968)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
(cherry picked from commit 9052f7a)

Co-authored-by: Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com>
Comment thread Python/compile.c

outermost = (comprehension_ty) asdl_seq_GET(generators, 0);
if (IS_TOP_LEVEL_AWAIT(c)) {
c->u->u_ste->ste_coroutine = 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this was over aggressive, it marks even non-async list comprehensions as coroutine, which breaks IPython/Jupyter. It should be marked as ste_coroutine only if await is somewhere.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL