Skip to content
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-119102: Fix error being thrown on quit when REPL has TERM=dumb #119328

Closed
wants to merge 6 commits into from

Conversation

eugenetriguba
Copy link
Contributor

@eugenetriguba eugenetriguba commented May 21, 2024

This fixes the issue where an InvalidTerminal error is being thrown when TERM is set to dumb.

(venv)  src/cpython (gh-119102) % ./python.exe
Python 3.14.0a0 (heads/main-dirty:ab4263a82a, May 21 2024, 11:15:42) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
(venv)  src/cpython (gh-119102) % TERM=dumb ./python.exe
Python 3.14.0a0 (heads/main-dirty:ab4263a82a, May 21 2024, 11:15:42) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
warning: can't use pyrepl: terminal doesn't have the required clear capability
>>> quit()
(venv)  src/cpython (gh-119102) %

On the main branch, we have the following behavior:

(venv)  src/cpython (main) % TERM=dumb ./python.exe
Python 3.14.0a0 (heads/main-dirty:ab4263a82a, May 21 2024, 11:15:42) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
warning: can't use pyrepl: terminal doesn't have the required clear capability
>>> quit()
Exception ignored in atexit callback <function register_readline.<locals>.write_history at 0x103b57a10>:
Traceback (most recent call last):
  File "/Users/eugene/src/cpython/Lib/site.py", line 531, in write_history
    _pyrepl.readline.write_history_file(history)
  File "/Users/eugene/src/cpython/Lib/_pyrepl/readline.py", line 364, in write_history_file
    history = self.get_reader().get_trimmed_history(maxlength)
  File "/Users/eugene/src/cpython/Lib/_pyrepl/readline.py", line 280, in get_reader
    console = UnixConsole(self.f_in, self.f_out, encoding=ENCODING)
  File "/Users/eugene/src/cpython/Lib/_pyrepl/unix_console.py", line 180, in __init__
    self._clear = _my_getstr("clear")
  File "/Users/eugene/src/cpython/Lib/_pyrepl/unix_console.py", line 173, in _my_getstr
    raise InvalidTerminal(
_pyrepl.unix_console.InvalidTerminal: terminal doesn't have the required clear capability

TODO: The test needs a little bit of tweaking still.

@ambv ambv added the topic-repl Related to the interactive shell label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-repl Related to the interactive shell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants