Repository navigation
Closed
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
To reproduce
(order doesn't matter)
- Open the new REPL
- Resize the terminal emulator window to be less than 5 cells wide
Traceback
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/__main__.py", line 6, in <module>
__pyrepl_interactive_console()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/main.py", line 59, in interactive_console
run_multiline_interactive_console(console)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/simple_interact.py", line 151, in run_multiline_interactive_console
statement = multiline_input(more_lines, ps1, ps2)
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/readline.py", line 389, in multiline_input
return reader.readline()
~~~~~~~~~~~~~~~^^
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/reader.py", line 801, in readline
self.handle1()
~~~~~~~~~~~~^^
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/reader.py", line 770, in handle1
self.refresh()
~~~~~~~~~~~~^^
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/reader.py", line 691, in refresh
self.screen = self.calc_screen()
~~~~~~~~~~~~~~~~^^
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/completing_reader.py", line 261, in calc_screen
screen = super().calc_screen()
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/reader.py", line 413, in calc_screen
self.cxy = self.pos2xy()
~~~~~~~~~~~^^
File "/Users/trag1c/.pyenv/versions/3.13.0/lib/python3.13/_pyrepl/reader.py", line 595, in pos2xy
p, l2 = self.screeninfo[y]
~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
The relevant fragment of code
Lines 587 to 596 in f4e5643
| def pos2xy(self) -> tuple[int, int]: | |
| """Return the x, y coordinates of position 'pos'.""" | |
| # this *is* incomprehensible, yes. | |
| y = 0 | |
| pos = self.pos | |
| assert 0 <= pos <= len(self.buffer) | |
| if pos == len(self.buffer): | |
| y = len(self.screeninfo) - 1 | |
| p, l2 = self.screeninfo[y] | |
| return p + sum(l2) + l2.count(0), y |
An additional demo
Screen.Recording.2024-11-27.at.11.47.29.PM.mov
CPython versions tested on:
3.13, 3.14
Operating systems tested on:
Linux, macOS
Linked PRs
Reacted by RubikCubed, Kirill Podoprigora, Mikhail Efimov, Andrey Karchevsky, Seyfullah Orhan and Micael Jarniac
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
gh-127349: Add check for correct resizing in REPL (#127387)
pythongh-127349: Add check for correct resizing in REPL (python#127387)
[3.13] gh-127349: Add check for correct resizing in REPL (GH-127387) (#…
pythongh-127349: Add check for correct resizing in REPL (python#127387)