You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
_pyrepl: AssertionError in pos2xy when recalling long multi-line wide-character history #159459
On CPython 3.14.6, the default REPL (_pyrepl) crashes with an AssertionError when recalling a long multi-line history entry that contains wide characters (CJK, emoji, etc.).
Trigger: enter a long multi-line string made of wide characters, press Enter, then press Up to recall it.
Half-width / ASCII characters do not trigger this. All full-width characters tested (Chinese, emoji) do.
After pressing Enter, press the Up arrow to recall the history entry. The REPL crashes.
Traceback
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 674, in do_cmd
self.update_cursor()
File ".../_pyrepl/reader.py", line 569, in update_cursor
self.cxy = self.pos2xy()
File ".../_pyrepl/reader.py", line 537, in pos2xy
assert 0 <= pos <= len(self.buffer)
AssertionError
Would love to take a look at this. However wasn't able to repro either. What terminal did you test? Also you mention some emojis, can you provide examples?
I am curious if you print a on the terminal, does it render correctly?
My guess would be that this is a weird issue with the terminal emulator not receiving the input correctly
Activity
encukou commentedon Oct 15, 2026
Which terminal are you using?
(I could not reproduce with Tilix, Gnome Terminal & Konsole.)
edvilme commentedon Oct 15, 2026
Would love to take a look at this. However wasn't able to repro either. What terminal did you test? Also you mention some emojis, can you provide examples?
nsyhykui commentedon Oct 15, 2026
nsyhykui commentedon Oct 15, 2026
Also reproducible in a wide terminal if a single line is long enough (many characters on one line).
edvilme commentedon Oct 15, 2026
I am curious if you print
aon the terminal, does it render correctly?My guess would be that this is a weird issue with the terminal emulator not receiving the input correctly
nsyhykui commentedon Oct 15, 2026
Yes,
print(a)works fine.nsyhykui commentedon Oct 16, 2026
I built CPython 3.16 from main and cannot reproduce this anymore. The bug seems to be fixed on main, but still present in 3.14.6 and 3.13.5.
encukou commentedon Oct 16, 2026
I cannot reproduce on those versions either :(
nsyhykui commentedon Oct 16, 2026
Two details that seem to be required to reproduce this:
stty size→ 49 88). With a wider terminal, the wide-character lines wrap less and the crash doesn't happen.Could you try with a 49-column terminal and press Up twice?
nsyhykui commentedon Oct 16, 2026
Maybe try this:
encukou commentedon Oct 16, 2026
Ah, that did it. Thank you!
Bisection shows this was fixed in 3.15 by #146584... which is unfortunately a big refactoring :(
nsyhykui commentedon Oct 17, 2026
Thanks for the bisect! I'll just wait for 3.15 then.