gh-119512: Use new REPL for the code module#148261
gh-119512: Use new REPL for the code module#148261tanloong wants to merge 9 commits intopython:mainfrom
Conversation
| the basic readline-based REPL is used. When ``None``, pyrepl is used | ||
| automatically if available and the :envvar:`PYTHON_BASIC_REPL` environment | ||
| variable is not set. |
There was a problem hiding this comment.
Why not make None behavior - default, and get rid of the use_pyrepl option? Users can override this by setting PYTHON_BASIC_REPL.
I presume, new option was chosen on ground backward-compatibility, but new REPL is an incompatible change by itself, this is just a continuation.
So, I think it's fine to remove added option, but please wait first feedback from core developers.
There was a problem hiding this comment.
Thanks for your review!
I believe adding the use_pyrepl parameter is necessary, and it should default to False rather than None.
Many third-party projects subclass code.InteractiveConsole to implement custom shells (1.2k search results on GitHub). CPython's own sqlite3 CLI also builds on code.InteractiveConsole and relies on GNU Readline for completion. If we enable the new REPL by default, its completion will break, and we will also see incorrect syntax highlighting: tokens in SQLite statements that coincide with Python keywords will be highlighted mistakenly by PyREPL. Similar issues would affect those among the 1.2k subclasses that implemented their own custom syntax and completions.
For backward compatibility, I think keeping use_pyrepl=False as the default is the safest approach.
This adds an optional
use_pyrepl: bool|None=Falseparameter tocode.InteractiveConsole.interact()andcode.interact().When set as
True, pyrepl is used. WhenFalse(the default), the basic readline-based REPL is used. WhenNone, pyrepl is used if available and thePYTHON_BASIC_REPLenvironment variable is not set.