Repository navigation
Use new REPL for the "code" module #119512
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on May 24, 2024 Is this an acceptable workaround before Python 3.14 is released?
It's unsupported as the underscore in the module name suggests. External projects will do as they please.
Reacted by Trey Hunner and Tushar Sadhwani- addedtopic-replRelated to the interactive shellRelated to the interactive shell
on May 24, 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:- 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, whereasrlcompleterdoes not). - A custom displayhook to render certain objects more like a debugger would.
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?Reacted by Nils KWe'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.Reacted by Stephen Brennan, Trey Hunner, Omar Sandoval, Adam Johnson, Nils K and Savio MakOk, 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.
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Oct 2, 2025
Feature or enhancement
Proposal:
When installing Django in a Python 3.13 virtual environment and using Django's
shellcommand, the old REPL is used.It would be great if the
codemodule 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
shellcommand in one's own project to use the new REPL, by using this within atry-exceptblock:Is this an acceptable workaround before Python 3.14 is released? Or should this function not be relied on, seeing as it's in an undocumented module?
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
#119433 (review)
Linked PRs