Skip to content

Crash when matching line in history has specific length #767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BenWiederhake opened this issue Mar 3, 2019 · 0 comments
Closed

Crash when matching line in history has specific length #767

BenWiederhake opened this issue Mar 3, 2019 · 0 comments

Comments

@BenWiederhake
Copy link

BenWiederhake commented Mar 3, 2019

Warning, this bug can "corrupt" your ~/.pythonhist. Before exploring it, make a backup of that file, and be prepared to delete it often.

Steps to reproduce: Write a command that has the size of precisely the screen length, as in: After typing the last character, a newline should happen. (This is another bug, but I don't care about it.) Press enter. Then type the first character of that command.

Expected behavior: bpython suggests the previous command.
Actual behavior: bpython crashes immediately after typing that first character.

Example session:

bpython version 0.17.1 on top of Python 3.7.2+ /usr/bin/python3
>>> s = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
>>> 
Traceback (most recent call last):
  File "/usr/bin/bpython3", line 11, in <module>
    load_entry_point('bpython==0.17.1', 'console_scripts', 'bpython')()
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 191, in main
    exit_value = repl.mainloop(True, paste)
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 126, in mainloop
    self.process_event_and_paint(e)
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 100, in process_event_and_paint
    array, cursor_pos = self.paint()
  File "/usr/lib/python3/dist-packages/bpython/curtsiesfrontend/repl.py", line 1497, in paint
    if self.matches_iter.completer else None)
  File "/usr/lib/python3/dist-packages/bpython/curtsiesfrontend/replpainter.py", line 181, in paint_infobox
    return fsarray(0, 0)
  File "/usr/lib/python3/dist-packages/curtsies/formatstringarray.py", line 48, in fsarray
    strings = list(strings)
TypeError: 'int' object is not iterable
[$? = 1]

Note that I'm not sure about the set of vulnerable lengths. It may be that the bug-criterion is more general, but the above recipe always produces a crash.

Here's a screen capture of the bug happening:
bpython3-screen-overflow.zip

This bug seems unrelated from #113, since the stacktrace is very different.

EDIT: Yeah, I know, sorry for constantly running into weird edge cases. But I swear, I didn't want to run into this one! Or any of the others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant