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
Crash when print ANSI escape code to color output text #915
Tried printing out an ANSI escape sequence that changes the color of terminal output to red (see: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors), and it crashed. If I don't pass the end='' parameter to the print function, it works fine; looks like bpython was expecting the cursor to advance but only changing the color doesn't do that.
~ % bpython
bpython version 0.21 on top of Python 3.8.2 /Library/Developer/CommandLineTools/usr/bin/python3
>>> print('\033[91m', end='')
Traceback (most recent call last):
File "/Users/arian/Library/Python/3.8/bin/bpython", line 8, in <module>
sys.exit(main())
File "/Users/arian/Library/Python/3.8/lib/python/site-packages/bpython/curtsies.py", line 201, in main
exit_value = repl.mainloop(True, paste)
File "/Users/arian/Library/Python/3.8/lib/python/site-packages/bpython/curtsies.py", line 121, in mainloop
self.process_event_and_paint(e)
File "/Users/arian/Library/Python/3.8/lib/python/site-packages/bpython/curtsies.py", line 95, in process_event_and_paint
array, cursor_pos = self.paint()
File "/Users/arian/Library/Python/3.8/lib/python/site-packages/bpython/curtsiesfrontend/repl.py", line 1610, in paint
assert cursor_row >= 0 and cursor_column >= 0, (
AssertionError: (-1, 74, 9, 0, 0)
This bug might even be the most pressing bug right now? It's been an issue for a long time though, so it's not urgent. It looks pretty involved, decisions made here about how we handle operationally blank output lines may have far-reaching effects.
I'm starting on some mypy types, that's a potential thing to work on if that's fun. In the autocompletion vein, you could take a look at #889 or #897 or similar. I'm interested in #826, which is related to the escape codes issue.
Activity
arian-deimling commentedon Sep 25, 2021
Can I work on this or are you going to?
arian-deimling commentedon Oct 2, 2021
Duplicate of #900.
thomasballinger commentedon Oct 7, 2021
@arian-deimling late to reply, but you're welcome to look. I suspect https://github.com/bpython/curtsies/blob/main/curtsies/escseqparse.py may be useful to look at, and that we may need to special case printing what we're going to treat as printing nothing.
arian-deimling commentedon Oct 7, 2021
@thomasballinger I'd be happy to look at this over the weekend. Do you want me to work on this or is there anything else that's more pressing?
thomasballinger commentedon Oct 7, 2021
This bug might even be the most pressing bug right now? It's been an issue for a long time though, so it's not urgent. It looks pretty involved, decisions made here about how we handle operationally blank output lines may have far-reaching effects.
I'm starting on some mypy types, that's a potential thing to work on if that's fun. In the autocompletion vein, you could take a look at #889 or #897 or similar. I'm interested in #826, which is related to the escape codes issue.