gh-118894: Make asyncio REPL use pyrepl#119433
Conversation
gvanrossum
left a comment
There was a problem hiding this comment.
Thanks for thinking of this! I’m AFK, but can review later. Wondering though… Could we change ‘code’ to always use this?
gvanrossum
left a comment
There was a problem hiding this comment.
I don't think I can review the changes to _pyrepl itself, but here's a review of the asyncio changes. Nothing earth-shattering. :-)
|
Another difference (inspired by the issue): If you hit ^C this just prints a blank line; the real REPL prints a message |
Interesting idea. We'll consider it for Python 3.14. |
|
The asyncio part LGTM now. Thanks again! |
| def repaint(self) -> None: ... | ||
|
|
||
|
|
||
| class InteractiveColoredConsole(code.InteractiveConsole): |
There was a problem hiding this comment.
I moved this here so it can be imported even when _pyrepl.readline doesn't import (which is imported by _pyrepl.simple_interact).
| the_symbol = symbol if stmt is last_stmt else "exec" | ||
| item = wrapper([stmt]) | ||
| try: | ||
| code = self.compile.compiler(item, filename, the_symbol, dont_inherit=True) |
There was a problem hiding this comment.
We actually want to use our console's compiler because then we can set custom flags, like top-level await.
| e.add_note( | ||
| f"Try the asyncio REPL ({python} -m asyncio) to use" | ||
| f" top-level 'await' and run background asyncio tasks." | ||
| ) |
There was a problem hiding this comment.
Python REPL, now with ads.
|
Thanks @ambv for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
(cherry picked from commit 2237946) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
|
GH-119884 is a backport of this pull request to the 3.13 branch. |
|
Whoopee! I was going to propose to make this the default, but there are some issues, e.g. creating a thread and an event loop by default. Still, very happy with this. |
PYTHON_BASIC_REPLexit()andexitbehave the sameKeyboardInterrupton CTRL-C like regular pyreplpython -m asyncio#118894