Open
Description
I'm surprised I haven't found another issue raised about this, or maybe I missed it.
This is a frequent problem for me. If I am in the bpython
shell and try to print out a large data structure, the shell crashes and it is frustrating. The big selling point of entering the shell is to be interactive with the environment, which means sometimes I want to display my data.
In this specific instance, I have a nested list structure. that looks like this
[
["string","string","string"..],
["string","string","string"..],
...
]
When I do a bit of debugging
sum([len(y) for x in my_nested_list[:50] for y in x])
I get 36453
. So this means the excerpt I'm going to "print" to my screen has 36,453 bytes of characters in it, spread across 30 nested lists.
In bpython
shell, when I simply do
>>> my_nested_list[:50]
The shell crashes:
Traceback (most recent call last):
File "/path/to/venv/bin/bpython", line 8, in <module>
sys.exit(main())
~~~~^^
File "/path/to/venv/lib64/python3.13/site-packages/bpython/curtsies.py", line 245, in main
repl.mainloop(True, paste)
~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/path/to/venv/lib64/python3.13/site-packages/bpython/curtsies.py", line 178, in mainloop
self.process_event_and_paint(e)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/path/to/venv/lib64/python3.13/site-packages/bpython/curtsies.py", line 149, in process_event_and_paint
scrolled = self.window.render_to_terminal(array, cursor_pos)
File "/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py", line 491, in render_to_terminal
self.scroll_down()
~~~~~~~~~~~~~~~~^^
File "/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py", line 56, in scroll_down
with self.t.location(x=0, y=1000000):
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.13/contextlib.py", line 141, in __enter__
return next(self.gen)
File "/path/to/venv/lib64/python3.13/site-packages/blessed/terminal.py", line 594, in location
self.stream.flush()
~~~~~~~~~~~~~~~~~^^
File "/path/to/venv/lib64/python3.13/site-packages/bpython/curtsiesfrontend/repl.py", line 623, in sigwinch_handler
cursor_dy = self.get_cursor_vertical_diff()
File "/path/to/venv/lib64/python3.13/site-packages/bpython/curtsies.py", line 118, in get_cursor_vertical_diff
return self.window.get_cursor_vertical_diff()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py", line 398, in get_cursor_vertical_diff
cursor_dy += self._get_cursor_vertical_diff_once()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py", line 406, in _get_cursor_vertical_diff_once
row, col = self.get_cursor_position()
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py", line 315, in get_cursor_position
return self.t.get_location()
~~~~~~~~~~~~~~~~~~~^^
File "/path/to/venv/lib64/python3.13/site-packages/blessed/terminal.py", line 651, in get_location
match = self._query_response(
self.u7 or u'\x1b[6n', self.caps['cursor_report'].re_compiled, timeout
)
File "/path/to/venv/lib64/python3.13/site-packages/blessed/terminal.py", line 528, in _query_response
self.stream.flush()
~~~~~~~~~~~~~~~~~^^
RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>
Metadata
Metadata
Assignees
Labels
No labels