cpython
cpython copied to clipboard
gh-118877: Fix AssertionError crash in pyrepl
A crash of the new pyrepl was triggered by pressing up arrow when tab completion menu was displayed. Fixes #118877
While this simple fix does the trick, as @lysnikolaou mentioned in a https://github.com/python/cpython/issues/118877#issuecomment-2104840020, there are other issues with how arrows interact with tab completions menu, so a more holistic fix might be needed eventually. I am hoping this is still useful to at least stop interpreter from crashing. Also the added test can serve is as a regression test.
(it took me quite a while to figure out how to write the test, suggestions how to improve it are welcome :pray: )
- Issue: gh-118877