python / python/cpython

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

未关闭
#131,430 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

3.13 3.14 stdlib topic-repl type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

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
  • gh-131452

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 pyrepl/commands.py 的第 152-156 行附近开始,这里描述了向后删除单词和 kill_range。在 REPL 中重现空行上的 ^W 后跟 ^K 序列,并跟踪 kill-ring 的状态。当该序列不再引发报告的 readline 异常时即表示完成;关联的 PR gh-131452 表明相关工作已经在进行中。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
cli
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。