Skip to content

_pyrepl: IndexError in max_column when recalling a very long single-line history entry #159617

Open

Description

@nsyhykui

Bug report

Bug description

On CPython 3.14.6, the default REPL (_pyrepl) crashes with IndexError when recalling a very long single-line history entry and then pressing Down repeatedly.

This reproduces with plain ASCII.

Minimal reproducer

  1. Launch a narrow xterm:
xterm -geometry 20x10
  1. In the Python REPL, enter a very long single line (1000 a characters on one line), e.g.:
a = """
aaaa... (1000 a's, single line)
"""
  1. Press Up several times, then press Down repeatedly.

Traceback

Traceback (most recent call last):
  File ".../_pyrepl/readline.py", line 395, in multiline_input
    return reader.readline()
  File ".../_pyrepl/reader.py", line 759, in readline
    self.handle1()
  File ".../_pyrepl/reader.py", line 742, in handle1
    self.do_cmd(cmd)
  File ".../_pyrepl/reader.py", line 667, in do_cmd
    command.do()
  File ".../_pyrepl/commands.py", line 299, in do
    new_x := r.max_column(new_y)
  File ".../_pyrepl/reader.py", line 463, in max_column
    return self.screeninfo[y][0] + sum(self.screeninfo[y][1])
IndexError: list index out of range

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    topic-replRelated to the interactive shell
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions