-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-118894: Make asyncio REPL use pyrepl #119433
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @ambv. It's so great to see the PyREPL come to life.
P.S. Code looks good but Windows is grumpy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for thinking of this! I’m AFK, but can review later. Wondering though… Could we change ‘code’ to always use this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
@@ -136,3 +139,45 @@ def wait(self) -> None: | |||
|
|||
@abstractmethod | |||
def repaint(self) -> None: ... | |||
|
|||
|
|||
class InteractiveColoredConsole(code.InteractiveConsole): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_REPL
exit()
andexit
behave the sameKeyboardInterrupt
on CTRL-C like regular pyreplpython -m asyncio
#118894