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
AssertionError when print()ing carriage return character #900
$ bpython
bpython version 0.21 on top of Python 3.9.4 /Users/hop/Library/PipXEnvs/venvs/bpython/bin/python
>>> print('', end='\r')
Traceback (most recent call last):
File "/Users/hop/bin/bpython", line 8, in <module>
sys.exit(main())
File "/Users/hop/Library/PipXEnvs/venvs/bpython/lib/python3.9/site-packages/bpython/curtsies.py", line 201, in main
exit_value = repl.mainloop(True, paste)
File "/Users/hop/Library/PipXEnvs/venvs/bpython/lib/python3.9/site-packages/bpython/curtsies.py", line 121, in mainloop
self.process_event_and_paint(e)
File "/Users/hop/Library/PipXEnvs/venvs/bpython/lib/python3.9/site-packages/bpython/curtsies.py", line 95, in process_event_and_paint
array, cursor_pos = self.paint()
File "/Users/hop/Library/PipXEnvs/venvs/bpython/lib/python3.9/site-packages/bpython/curtsiesfrontend/repl.py", line 1610, in paint
assert cursor_row >= 0 and cursor_column >= 0, (
AssertionError: (-1, 79, 5, 0, 0)
Another variation leading to a crash is print('\r', end='').
print('\r\n', end='') does not crash, while print('\n\r', end='') will.
This issue is over 8 months old, why has nothing been done here?
I use these printing methods all the time, and this is the only reason why I am not using bpython atm.
Although print('\r\n') doesn't assert, it also seems to have some very odd behavior with how the output is rendered, which I can reproduce by printing a multiline string several times (bpython version 0.24 on top of Python 3.11.5 on macOS). The issue goes away if I .replace("\r", "") on the string before printing.
Edit: more info about my environment. I can attach full logs if needed.
Each of these is exactly the same string, but the output only appears once the input prompt has gotten low enough in my terminal to scroll it. (tested on iTerm2 and VSCode builtin terminal).
Seems this issue has been open a while and #915 is closed, but mentions that it might be a curtsies issue? For now just removing \r from strings seems to be a workaround for me, but if you actually need to print carriage returns I could see this being an issue.
Activity
arian-deimling commentedon Oct 2, 2021
This issue has the same root cause as #915.
eabase commentedon Feb 2, 2022
This issue is over 8 months old, why has nothing been done here?
I use these printing methods all the time, and this is the only reason why I am not using bpython atm.
ian-h-chamberlain commentedon Sep 21, 2023
Although
print('\r\n')doesn't assert, it also seems to have some very odd behavior with how the output is rendered, which I can reproduce by printing a multiline string several times (bpython version 0.24 on top of Python 3.11.5on macOS). The issue goes away if I.replace("\r", "")on the string before printing.Edit: more info about my environment. I can attach full logs if needed.
Each of these is exactly the same string, but the output only appears once the input prompt has gotten low enough in my terminal to scroll it. (tested on iTerm2 and VSCode builtin terminal).
Seems this issue has been open a while and #915 is closed, but mentions that it might be a
curtsiesissue? For now just removing\rfrom strings seems to be a workaround for me, but if you actually need to print carriage returns I could see this being an issue.