Title: Bpython breaks when printing large data structures · Issue #1037 · bpython/bpython · GitHub
Open Graph Title: Bpython breaks when printing large data structures · Issue #1037 · bpython/bpython
X Title: Bpython breaks when printing large data structures · Issue #1037 · bpython/bpython
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. Th...
Open Graph 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...
X 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 struct...
Opengraph URL: https://github.com/bpython/bpython/issues/1037
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bpython breaks when printing large data structures","articleBody":"I'm surprised I haven't found another issue raised about this, or maybe I missed it.\n\nThis 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.\n\nIn this specific instance, I have a nested list structure. that looks like this\n\n```\n[\n [\"string\",\"string\",\"string\"..],\n [\"string\",\"string\",\"string\"..],\n ...\n]\n```\n\nWhen I do a bit of debugging\n```python\nsum([len(y) for x in my_nested_list[:50] for y in x])\n```\nI 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.\n\nIn `bpython` shell, when I simply do\n```\n\u003e\u003e\u003e my_nested_list[:50]\n```\nThe shell crashes:\n```\nTraceback (most recent call last):\n File \"/path/to/venv/bin/bpython\", line 8, in \u003cmodule\u003e\n sys.exit(main())\n ~~~~^^\n File \"/path/to/venv/lib64/python3.13/site-packages/bpython/curtsies.py\", line 245, in main\n repl.mainloop(True, paste)\n ~~~~~~~~~~~~~^^^^^^^^^^^^^\n File \"/path/to/venv/lib64/python3.13/site-packages/bpython/curtsies.py\", line 178, in mainloop\n self.process_event_and_paint(e)\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^\n File \"/path/to/venv/lib64/python3.13/site-packages/bpython/curtsies.py\", line 149, in process_event_and_paint\n scrolled = self.window.render_to_terminal(array, cursor_pos)\n File \"/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py\", line 491, in render_to_terminal\n self.scroll_down()\n ~~~~~~~~~~~~~~~~^^\n File \"/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py\", line 56, in scroll_down\n with self.t.location(x=0, y=1000000):\n ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^\n File \"/usr/lib64/python3.13/contextlib.py\", line 141, in __enter__\n return next(self.gen)\n File \"/path/to/venv/lib64/python3.13/site-packages/blessed/terminal.py\", line 594, in location\n self.stream.flush()\n ~~~~~~~~~~~~~~~~~^^\n File \"/path/to/venv/lib64/python3.13/site-packages/bpython/curtsiesfrontend/repl.py\", line 623, in sigwinch_handler\n cursor_dy = self.get_cursor_vertical_diff()\n File \"/path/to/venv/lib64/python3.13/site-packages/bpython/curtsies.py\", line 118, in get_cursor_vertical_diff\n return self.window.get_cursor_vertical_diff()\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^\n File \"/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py\", line 398, in get_cursor_vertical_diff\n cursor_dy += self._get_cursor_vertical_diff_once()\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^\n File \"/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py\", line 406, in _get_cursor_vertical_diff_once\n row, col = self.get_cursor_position()\n ~~~~~~~~~~~~~~~~~~~~~~~~^^\n File \"/path/to/venv/lib64/python3.13/site-packages/curtsies/window.py\", line 315, in get_cursor_position\n return self.t.get_location()\n ~~~~~~~~~~~~~~~~~~~^^\n File \"/path/to/venv/lib64/python3.13/site-packages/blessed/terminal.py\", line 651, in get_location\n match = self._query_response(\n self.u7 or u'\\x1b[6n', self.caps['cursor_report'].re_compiled, timeout\n )\n File \"/path/to/venv/lib64/python3.13/site-packages/blessed/terminal.py\", line 528, in _query_response\n self.stream.flush()\n ~~~~~~~~~~~~~~~~~^^\nRuntimeError: reentrant call inside \u003c_io.BufferedWriter name='\u003cstdout\u003e'\u003e\n```","author":{"url":"https://github.com/truck-iguana","@type":"Person","name":"truck-iguana"},"datePublished":"2025-04-27T18:00:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1037/bpython/issues/1037"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f54af03d-ef9e-4332-88ca-5481005cbe74 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 96E0:197DB9:561F94:7AFBBD:69675315 |
| html-safe-nonce | 7b98b8fe06c035f08f04611733e74d594a75c1f8d72d96eb0030e2e7937a0aa0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkUwOjE5N0RCOTo1NjFGOTQ6N0FGQkJEOjY5Njc1MzE1IiwidmlzaXRvcl9pZCI6IjY0MjIxODU1NDYzMDkxMjg5ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 60ed89250ed5272838da8357184e85fa9674aadf1ea74e15a417f9f99ca326cd |
| hovercard-subject-tag | issue:3023233337 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bpython/bpython/1037/issue_layout |
| twitter:image | https://opengraph.githubassets.com/95f4633bd082c44e7f6593768188976f649e9b64446fbaf11c8af90f8d6dd91f/bpython/bpython/issues/1037 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/95f4633bd082c44e7f6593768188976f649e9b64446fbaf11c8af90f8d6dd91f/bpython/bpython/issues/1037 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | truck-iguana |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1a6a4ac66aaa8be0077b72a69fd56fb51cd11215a1e31f0365079e012987234a |
| turbo-cache-control | no-preview |
| go-import | github.com/bpython/bpython git https://github.com/bpython/bpython.git |
| octolytics-dimension-user_id | 8071396 |
| octolytics-dimension-user_login | bpython |
| octolytics-dimension-repository_id | 21508865 |
| octolytics-dimension-repository_nwo | bpython/bpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21508865 |
| octolytics-dimension-repository_network_root_nwo | bpython/bpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 045909cd564d790cacd96dcb8722039dff679d63 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width