Title: Bug in linecache when raising exceptiongroup that contains `ZeroDivisionError` + other exception. · Issue #101517 · python/cpython · GitHub
Open Graph Title: Bug in linecache when raising exceptiongroup that contains `ZeroDivisionError` + other exception. · Issue #101517 · python/cpython
X Title: Bug in linecache when raising exceptiongroup that contains `ZeroDivisionError` + other exception. · Issue #101517 · python/cpython
Description: Bug report Consider this code: from asyncio import run, TaskGroup async def bad_function(): raise ZeroDivisionError async def bad_function2(): raise KeyError async def main(): try: async with TaskGroup() as tg: tg.create_task(bad_functio...
Open Graph Description: Bug report Consider this code: from asyncio import run, TaskGroup async def bad_function(): raise ZeroDivisionError async def bad_function2(): raise KeyError async def main(): try: async with TaskG...
X Description: Bug report Consider this code: from asyncio import run, TaskGroup async def bad_function(): raise ZeroDivisionError async def bad_function2(): raise KeyError async def main(): try: async with TaskG...
Opengraph URL: https://github.com/python/cpython/issues/101517
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug in linecache when raising exceptiongroup that contains `ZeroDivisionError` + other exception.","articleBody":"# Bug report\r\n\r\nConsider this code:\r\n\r\n```python\r\nfrom asyncio import run, TaskGroup\r\n\r\nasync def bad_function():\r\n raise ZeroDivisionError\r\nasync def bad_function2():\r\n raise KeyError\r\n\r\nasync def main():\r\n try:\r\n async with TaskGroup() as tg:\r\n tg.create_task(bad_function())\r\n tg.create_task(bad_function2())\r\n\r\n except* ZeroDivisionError as e:\r\n breakpoint()\r\n\r\n\r\nrun(main())\r\n```\r\n\r\nRun it on Python 3.11 or 3.12:\r\n\r\n```pytb\r\n--Return--\r\nTraceback (most recent call last):\r\n File \"....py\", line 18, in \u003cmodule\u003e\r\n run(main())\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/asyncio/runners.py\", line 190, in run\r\n return runner.run(main)\r\n ^^^^^^^^^^^^^^^^\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/asyncio/runners.py\", line 118, in run\r\n return self._loop.run_until_complete(task)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/asyncio/base_events.py\", line 650, in run_until_complete\r\n return future.result()\r\n ^^^^^^^^^^^^^^^\r\n File \".....py\", line -1, in main\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/bdb.py\", line 94, in trace_dispatch\r\n return self.dispatch_return(frame, arg)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/bdb.py\", line 153, in dispatch_return\r\n self.user_return(frame, arg)\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/pdb.py\", line 372, in user_return\r\n self.interaction(frame, None)\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/pdb.py\", line 434, in interaction\r\n self.print_stack_entry(self.stack[self.curindex])\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/pdb.py\", line 1554, in print_stack_entry\r\n self.format_stack_entry(frame_lineno, prompt_prefix))\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/bdb.py\", line 573, in format_stack_entry\r\n line = linecache.getline(filename, lineno, frame.f_globals)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/linecache.py\", line 31, in getline\r\n if 1 \u003c= lineno \u003c= len(lines):\r\nTypeError: '\u003c=' not supported between instances of 'int' and 'NoneType'\r\n```\r\n\r\nOne of the exceptions has to be a `ZeroDivisionError` for it to happen as far as I can see.\r\n\r\n# Your environment\r\n\r\n- CPython versions tested on: 3.11, 3.12\r\n- Operating system and architecture: Linux, M1, arm64\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-101663\n* gh-101768\n* gh-101787\n* gh-101793\n* gh-101794\n* gh-103529\n* gh-103547\n* gh-103550\n* gh-103816\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/jonathanslenders","@type":"Person","name":"jonathanslenders"},"datePublished":"2023-02-02T16:09:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":30},"url":"https://github.com/101517/cpython/issues/101517"}
| 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:f4213b8e-d48b-b5ac-150d-f21fbaa8f097 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 97A2:11141E:7F18FE:AA8061:69697925 |
| html-safe-nonce | a7ab1a9676bb30d46b41241fbbaf78264301bcfd43c0b009d95cbbc6bb21bb1c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0EyOjExMTQxRTo3RjE4RkU6QUE4MDYxOjY5Njk3OTI1IiwidmlzaXRvcl9pZCI6IjkwNDQ3Njc2ODc2MzQ5NDIyNDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9ebbd5ddd28dc01ab918830bf5a45952af538261cd9ade021cc8dd066ed111cf |
| hovercard-subject-tag | issue:1568330545 |
| 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/101517/issue_layout |
| twitter:image | https://opengraph.githubassets.com/619af0fe49e2583e1444cc286cf2a7a24bdb6d12d6a48958004ba4d50aece097/python/cpython/issues/101517 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/619af0fe49e2583e1444cc286cf2a7a24bdb6d12d6a48958004ba4d50aece097/python/cpython/issues/101517 |
| og:image:alt | Bug report Consider this code: from asyncio import run, TaskGroup async def bad_function(): raise ZeroDivisionError async def bad_function2(): raise KeyError async def main(): try: async with TaskG... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jonathanslenders |
| hostname | github.com |
| expected-hostname | github.com |
| None | c6f193beb8ff08443adc07685d75302ab8aaf0a135f6e251c3ff3112c8deb881 |
| 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 | 212e3e3d3298bf5b313830edfd2399e869f7ea76 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width