Title: Py313 REPL crash on malformed `os.environ` · Issue #128636 · python/cpython · GitHub
Open Graph Title: Py313 REPL crash on malformed `os.environ` · Issue #128636 · python/cpython
X Title: Py313 REPL crash on malformed `os.environ` · Issue #128636 · python/cpython
Description: Bug description While researching a personal project bug, I made a typo in the REPL. Obviously, one shouldn't do like the following distilled MRE, but a crash is a crash so reporting it: $ python3.13 Python 3.13.1 (main, Dec 12 2024, 16:...
Open Graph Description: Bug description While researching a personal project bug, I made a typo in the REPL. Obviously, one shouldn't do like the following distilled MRE, but a crash is a crash so reporting it: $ python3....
X Description: Bug description While researching a personal project bug, I made a typo in the REPL. Obviously, one shouldn't do like the following distilled MRE, but a crash is a crash so reporting it: $ pyth...
Opengraph URL: https://github.com/python/cpython/issues/128636
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Py313 REPL crash on malformed `os.environ`","articleBody":"# Bug description\r\n\r\nWhile researching a personal project bug, I made a typo in the REPL. Obviously, one shouldn't do like the following distilled [MRE](https://en.wikipedia.org/wiki/Minimal_reproducible_example), but a crash is a crash so reporting it:\r\n\r\n```console\r\n$ python3.13\r\nPython 3.13.1 (main, Dec 12 2024, 16:35:44) [GCC 11.4.0] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n\u003e\u003e\u003e import os\r\n\u003e\u003e\u003e os.environ = []\r\nTraceback (most recent call last):\r\n File \"\u003cfrozen runpy\u003e\", line 198, in _run_module_as_main\r\n File \"\u003cfrozen runpy\u003e\", line 88, in _run_code\r\n File \".../.local/Python3.13.1/lib/python3.13/_pyrepl/__main__.py\", line 6, in \u003cmodule\u003e\r\n __pyrepl_interactive_console()\r\n File \".../.local/Python3.13.1/lib/python3.13/_pyrepl/main.py\", line 59, in interactive_console\r\n run_multiline_interactive_console(console)\r\n File \".../local/Python3.13.1/lib/python3.13/_pyrepl/simple_interact.py\", line 151, in run_multiline_interactive_console\r\n statement = multiline_input(more_lines, ps1, ps2)\r\n File \".../local/Python3.13.1/lib/python3.13/_pyrepl/readline.py\", line 389, in multiline_input\r\n return reader.readline()\r\n File \".../local/Python3.13.1/lib/python3.13/_pyrepl/reader.py\", line 795, in readline\r\n self.prepare()\r\n File \".../local/Python3.13.1/lib/python3.13/_pyrepl/historical_reader.py\", line 302, in prepare\r\n super().prepare()\r\n File \".../local/Python3.13.1/lib/python3.13/_pyrepl/reader.py\", line 635, in prepare\r\n self.console.prepare()\r\n File \".../local/Python3.13.1/lib/python3.13/_pyrepl/unix_console.py\", line 349, in prepare\r\n self.height, self.width = self.getheightwidth()\r\n File \".../local/Python3.13.1/lib/python3.13/_pyrepl/unix_console.py\", line 451, in getheightwidth\r\n return int(os.environ[\"LINES\"]), int(os.environ[\"COLUMNS\"])\r\nTypeError: list indices must be integers or slices, not str\r\n\r\n$ echo $?\r\n1\r\n```\r\n\r\nThis is clearly a PEBCAK interaction; the proper way to have cleared the environment would have been `.clear()` (and as an education point and/or reminder for search engine retrieval or others reading this later, `os.environ` and `os.environb` are \"special\" in that they're assumed to exist and are linked\u0026nbsp;\u0026mdash;\u0026nbsp;a change to one affects the other).\r\n\r\nBut, my late-night typo did produce an interpreter crash, so reporting here.\r\n\r\nNote that this does not appear to fail in Python up to v3.12. Python 3.13 is the first to crash this way.\r\n\r\n# Background\r\n\r\nI initially thought it was an IPython bug, and [so reported it there](https://github.com/ipython/ipython/issues/14638). @Carreau rightly course-corrected me, with a suggestion for a possible upstream fix in CPython.\r\n\r\n### CPython versions tested on:\r\n\r\n3.13\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-128653\n* gh-129186\n* gh-138089\n* gh-138938\n* gh-138942\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/khk-globus","@type":"Person","name":"khk-globus"},"datePublished":"2025-01-08T14:49:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/128636/cpython/issues/128636"}
| 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:b6a7ace9-f02a-c537-e7a4-fecd77c3eb25 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E65C:19D71A:DA05BA:12B854C:6A53AB2A |
| html-safe-nonce | 5dbb9057122973269f3dca2542e9e77b43ef3b91c99f6d2d559d64e2edacdba2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjVDOjE5RDcxQTpEQTA1QkE6MTJCODU0Qzo2QTUzQUIyQSIsInZpc2l0b3JfaWQiOiIxNTg5Mjc2MDYxODExODQ1OTMwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 28da41809e22a533a2b9a533cb5b78f1f5b24ecb00c6292cd5bf9085ded0622c |
| hovercard-subject-tag | issue:2775590137 |
| 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/python/cpython/128636/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f7b418b5d1598cd7e4ebe1e564147c1946a55d08fd365c3b52a1e2f0b9f7d14b/python/cpython/issues/128636 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f7b418b5d1598cd7e4ebe1e564147c1946a55d08fd365c3b52a1e2f0b9f7d14b/python/cpython/issues/128636 |
| og:image:alt | Bug description While researching a personal project bug, I made a typo in the REPL. Obviously, one shouldn't do like the following distilled MRE, but a crash is a crash so reporting it: $ python3.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | khk-globus |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width