You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When installing Django in a Python 3.13 virtual environment and using Django's shell command, the old REPL is used.
It would be great if the code module supported the new REPL. From @ambv's reply in #119433 (comment) it looks like this will be considered in Python 3.14.
I would also like to know what projects should do in the meantime. For example, I found a way to modify Django's shell command in one's own project to use the new REPL, by using this within a try-except block:
Hello, I work on drgn which is a debugger implemented as a Python library. One of the modes drgn has is to launch a Python REPL using the code module, with several variables and modules pre-imported.
We'd definitely love to see a supported way to use the improved REPL for the code module, so a big 👍 from us on this suggestion. The multiline editing is really exciting and a major usability enhancement, so thanks for all the work on that.
I did want to share a couple potential issues with using the pyrepl with the code module. Drgn has a few customizations to its REPL:
Using a custom history file, since the code you typically write in a drgn shell in very different from what you'd write in a normal Python shell.
A custom tab-completer which is like that provided by rlcompleter, but also supports completions on objects that are indexed by a string or number (e.g. object["foo"].<TAB> would provide a completion, whereas rlcompleter does not).
A custom displayhook to render certain objects more like a debugger would.
In fact, the readlinemodule documentation even has an example of configuring code.InteractiveInterpreter in a similar way (see the last code snippet at the bottom of the page).
If the code module switches to using _pyrepl, even optionally, then it would be really great to have a way to adjust the history file and completion options that are used. Is that something which would be in scope for this request?
We'll look into making code.py optionally use PyREPL in 3.14. It will require some code to be moved around as currently PyREPL actually depends on code.py.
Reacted by Stephen Brennan, Trey Hunner, Omar Sandoval, Adam Johnson, Nils K and Savio Mak
Ok, I'll try to address this issue: I depend on the code module to implement a customized repl for several projects (diofant, mpmath). I hope it's not too late for 3.14.
Activity
ambv commentedon May 24, 2024
It's unsupported as the underscore in the module name suggests. External projects will do as they please.
brenns10 commentedon Oct 16, 2024
Hello, I work on drgn which is a debugger implemented as a Python library. One of the modes drgn has is to launch a Python REPL using the
codemodule, with several variables and modules pre-imported.We'd definitely love to see a supported way to use the improved REPL for the
codemodule, so a big 👍 from us on this suggestion. The multiline editing is really exciting and a major usability enhancement, so thanks for all the work on that.I did want to share a couple potential issues with using the pyrepl with the
codemodule. Drgn has a few customizations to its REPL:rlcompleter, but also supports completions on objects that are indexed by a string or number (e.g.object["foo"].<TAB>would provide a completion, whereasrlcompleterdoes not).In fact, the
readlinemodule documentation even has an example of configuringcode.InteractiveInterpreterin a similar way (see the last code snippet at the bottom of the page).If the
codemodule switches to using_pyrepl, even optionally, then it would be really great to have a way to adjust the history file and completion options that are used. Is that something which would be in scope for this request?ambv commentedon Oct 16, 2024
We'll look into making
code.pyoptionally use PyREPL in 3.14. It will require some code to be moved around as currently PyREPL actually depends oncode.py.skirpichev commentedon Apr 11, 2025
Ok, I'll try to address this issue: I depend on the code module to implement a customized repl for several projects (diofant, mpmath). I hope it's not too late for 3.14.