Closed
Description
Bug report
Bug description:
Trying to paste zero-width characters (U+200B
, U+200C
, U+200D
, U+FEFF
) into the new REPL causes it to get stuck and keep allocating memory. Python 3.12 handles them fine.
This seems to happen during screen calculation, so the amount of characters needed to reproduce will depend on the number of cells in a terminal emulator window (I got it working with as few as 3 with a big enough zoom, but 100 should be enough).
A table with all of them x100 to copy for convenience:
ZWSP | ZWNJ | ZWJ | ZWNBSP |
---|---|---|---|
|
|
|
|
To reproduce
- Open the new REPL
- Paste in some zero-width characters
- The REPL should get stuck and keep allocating memory
- Can be stopped with double
^C
or a single^\
The culprit seems to be this loop in Lib/_pyrepl/reader.py:Reader.calc_screen
and its screen
/screen_info
appends:
Lines 388 to 411 in f4e5643
An additional demo
Screen.Recording.2024-11-11.at.13.52.32.mov
CPython versions tested on:
3.12, 3.13, CPython main branch
Operating systems tested on:
Linux, macOS