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

New REPL crashes on an empty DELETE_WORD_BACKWARDS (^W) followed by CLEAR_TO_START (^K) #131430

Open
Christopher-Chianelli opened this issue Mar 18, 2025 · 0 comments
Labels
stdlib Python modules in the Lib dir topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@Christopher-Chianelli
Copy link
Contributor

Christopher-Chianelli commented Mar 18, 2025

Bug report

Bug description:

If, in the REPL, you:

  1. Delete the current word, backward, on an empty line using Control-W, then
  2. Delete to the end of line, using Control-K

The REPL will crash with an exception in readline.

Note: ^ denotes pressing the Control or Command key when pressing the next character.

>>> ^W^KTraceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/lib64/python3.13/_pyrepl/__main__.py", line 6, in <module>
    __pyrepl_interactive_console()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.13/_pyrepl/main.py", line 59, in interactive_console
    run_multiline_interactive_console(console)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/lib64/python3.13/_pyrepl/simple_interact.py", line 143, in run_multiline_interactive_console
    statement = multiline_input(more_lines, ps1, ps2)
  File "/usr/lib64/python3.13/_pyrepl/readline.py", line 389, in multiline_input
    return reader.readline()
           ~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.13/_pyrepl/reader.py", line 802, in readline
    self.handle1()
    ~~~~~~~~~~~~^^
  File "/usr/lib64/python3.13/_pyrepl/reader.py", line 785, in handle1
    self.do_cmd(cmd)
    ~~~~~~~~~~~^^^^^
  File "/usr/lib64/python3.13/_pyrepl/reader.py", line 710, in do_cmd
    command.do()
    ~~~~~~~~~~^^
  File "/usr/lib64/python3.13/_pyrepl/commands.py", line 157, in do
    self.kill_range(r.pos, eol + 1)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/_pyrepl/commands.py", line 71, in kill_range
    r.kill_ring[-1] = r.kill_ring[-1] + text
                      ~~~~~~~~~~~^^^^

This exception is caused since kill_range is not called on an empty backward_kill_word, causing kill_ring to be empty: https://github.com/pypy/pyrepl/blob/ca192a80b76700118b9bfd261a3d098b92ccfc31/pyrepl/commands.py#L152-L156

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

@Christopher-Chianelli Christopher-Chianelli added the type-bug An unexpected behavior, bug, or error label Mar 18, 2025
@picnixz picnixz added stdlib Python modules in the Lib dir topic-repl Related to the interactive shell labels Mar 18, 2025
deepwzh added a commit to deepwzh/cpython that referenced this issue Mar 19, 2025
…ollowed by CLEAR_TO_START (^K)

Add the handling of kill_range null detection, which is a left closed and right open interval. When end start<=1, it means that no operation has been done and should be skipped; The original writing only handled the case of end==start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants