René's URL Explorer Experiment


Title: `exc_info` can get lost when `throw`ing into an `await` or `yield from` · Issue #108668 · python/cpython · GitHub

Open Graph Title: `exc_info` can get lost when `throw`ing into an `await` or `yield from` · Issue #108668 · python/cpython

X Title: `exc_info` can get lost when `throw`ing into an `await` or `yield from` · Issue #108668 · python/cpython

Description: Bug report Checklist I am confident this is a bug in CPython, not a bug in a third-party project I have searched the CPython issue tracker, and am confident this bug has not been reported before CPython versions tested on: 3.8, 3.9, 3.10...

Open Graph Description: Bug report Checklist I am confident this is a bug in CPython, not a bug in a third-party project I have searched the CPython issue tracker, and am confident this bug has not been reported before CP...

X Description: Bug report Checklist I am confident this is a bug in CPython, not a bug in a third-party project I have searched the CPython issue tracker, and am confident this bug has not been reported before CP...

Opengraph URL: https://github.com/python/cpython/issues/108668

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`exc_info` can get lost when `throw`ing into an `await` or `yield from`","articleBody":"# Bug report\r\n\r\n### Checklist\r\n\r\n- [X] I am confident this is a bug in CPython, not a bug in a third-party project\r\n- [X] I have searched the [CPython issue tracker](https://github.com/python/cpython/issues?q=is%3Aissue+sort%3Acreated-desc),\r\nand am confident this bug has not been reported before\r\n\r\n\r\n### CPython versions tested on:\r\n\r\n3.8, 3.9, 3.10, 3.11, 3.12, CPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\r\n\r\n### Output from running 'python -VV' on the command line:\r\n\r\nPython 3.11.5 (main, Aug 28 2023, 16:29:45) [GCC 13.2.1 20230801]\r\n\r\n### A clear and concise description of the bug:\r\n\r\nif an exception is active inside a coroutine/generator (`coro1`/`agen1`) and another exception is `.throw`n into its `await coro2`/`yield from agen2`, then `coro2`/`agen2` loses the original `exc_info`.\r\n\r\n*   a generator example:\r\n\r\n    ```python\r\n    import sys\r\n\r\n\r\n    def outer():\r\n        try:\r\n            raise RuntimeError(\"boom\")\r\n        except RuntimeError:  # or `__exit__`/`finally`\r\n            print(sys.exc_info())\r\n            yield from inner()\r\n            # note: if you inline `inner()` here, things work fine.\r\n            print(sys.exc_info())\r\n\r\n\r\n    def inner():\r\n        print(sys.exc_info())\r\n        try:\r\n            yield\r\n        except ValueError:\r\n            pass\r\n        print(sys.exc_info())\r\n\r\n\r\n    gen = outer()\r\n    gen.send(None)\r\n    try:\r\n        gen.throw(ValueError)\r\n    except StopIteration:\r\n        pass\r\n    ```\r\n\r\n    output:\r\n\r\n    ```\r\n    (\u003cclass 'RuntimeError'>, RuntimeError('boom'), \u003ctraceback object at 0x7fdb6b313840>)\r\n    (\u003cclass 'RuntimeError'>, RuntimeError('boom'), \u003ctraceback object at 0x7fdb6b313840>)\r\n    (None, None, None)\r\n    (\u003cclass 'RuntimeError'>, RuntimeError('boom'), \u003ctraceback object at 0x7fdb6b313840>)\r\n    ```\r\n\r\n    expected output:\r\n\r\n    same `exc_info` all four times.\r\n\r\n*   two coroutine examples (using asyncio in particular, with asyncio calling `throw`):\r\n\r\n    ```python\r\n    import asyncio\r\n    import sys\r\n    from asyncio import CancelledError\r\n    from math import inf\r\n\r\n\r\n    async def outer():\r\n        try:\r\n            raise RuntimeError(\"boom\")\r\n        except RuntimeError:  # or `__aexit__`/`finally`\r\n            print(sys.exc_info())\r\n            await clean_up_and_log()\r\n            # note: if you inline `clean_up_and_log()` here, things work fine.\r\n            print(sys.exc_info())\r\n\r\n\r\n    async def clean_up_and_log():\r\n        print(sys.exc_info())\r\n\r\n        # attempt to do some clean up that we are okay skipping part of if we get cancelled\r\n        # during it or if we already have a cancellation request.\r\n        #\r\n        # (to reproduce, suppose that we get a cancellation request before the optional\r\n        # clean up step.)\r\n        asyncio.current_task().cancel()\r\n        try:\r\n            await asyncio.sleep(0)\r\n        except CancelledError:\r\n            if sys.version_info >= (3, 11):\r\n                asyncio.current_task().uncancel()\r\n\r\n        # after the optional async clean up, log the exception.\r\n        print(sys.exc_info())\r\n\r\n\r\n    async def clean_up_and_log():  # this example is >= 3.11 only.\r\n        print(sys.exc_info())\r\n\r\n        # attempt to do some clean up that we want to skip if it takes too long (e.g. due to\r\n        # a non-responsive peer) or if we get cancelled during it or if we already have a\r\n        # cancellation request.\r\n        try:\r\n            async with asyncio.timeout(0.1):\r\n                await asyncio.sleep(inf)\r\n        except TimeoutError:\r\n            pass\r\n        except CancelledError:\r\n            asyncio.current_task().uncancel()\r\n\r\n        # after the optional async clean up, log the exception.\r\n        print(sys.exc_info())\r\n\r\n\r\n    asyncio.run(outer())\r\n    ```\r\n\r\n    output and expected output: same as the generator example.\r\n\r\nthis problem is a special case of GH-73773 that was not discussed or fixed as part of that issue[^1].\r\n\r\nfor comparison, PyPy behaves the way I expect here.\r\n\r\n[^1]: I am not sure whether it would be preferred that I necrobump the old closed issue or file a new report here.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-157235\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/gschaffner","@type":"Person","name":"gschaffner"},"datePublished":"2023-08-30T06:11:24Z","url":"https://github.com/python/cpython/issues/108668"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e7190f9e-a0a3-7b63-ecd3-b8a3b597cc5d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC1D6:39DC4B:59C7B8:7E3848:6B0078D3
html-safe-nonceecee1c4ba4fe71416528012deaa5ee9a16dfc89f118c6ed3a0cfad08d5bf717e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMUQ2OjM5REM0Qjo1OUM3Qjg6N0UzODQ4OjZCMDA3OEQzIiwidmlzaXRvcl9pZCI6IjQ0MDI0NjY1ODgyOTc1NTgyMjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacc2dbe8bdbbf730d3d2d3466bb449513c6872ed88cc21b441812b1107a7bc8d00
hovercard-subject-tagissue:1872978213
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/108668/issue_layout
twitter:imagehttps://opengraph.githubassets.com/761af498aab948e8998c5ef38e2ae892b6588cb7c7b7979c11a33b51c3ca9947/python/cpython/issues/108668
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/761af498aab948e8998c5ef38e2ae892b6588cb7c7b7979c11a33b51c3ca9947/python/cpython/issues/108668
og:image:altBug report Checklist I am confident this is a bug in CPython, not a bug in a third-party project I have searched the CPython issue tracker, and am confident this bug has not been reported before CP...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegschaffner
hostnamegithub.com
expected-hostnamegithub.com
None75c2b65dd205f26961d0c29afed1a8d0bb7cca9f05780571dfd1ef93eb539d16
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release84e563eb4b55f8fa102f325f117533cee9e3df4a
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/108668#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F108668
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F108668
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/108668
Reloadhttps://github.com/python/cpython/issues/108668
Reloadhttps://github.com/python/cpython/issues/108668
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/108668
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/108668
#157235https://github.com/python/cpython/pull/157235
exc_info can get lost when throwing into an await or yield fromhttps://github.com/python/cpython/issues/108668#top
#157235https://github.com/python/cpython/pull/157235
https://github.com/iritkatriel
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/gschaffner
gschaffnerhttps://github.com/gschaffner
on Aug 30, 2023https://github.com/python/cpython/issues/108668#issue-1872978213
CPython issue trackerhttps://github.com/python/cpython/issues?q=is%3Aissue+sort%3Acreated-desc
GH-73773https://github.com/python/cpython/issues/73773
1https://github.com/python/cpython/issues/108668#user-content-fn-1-1ddfe715394f68abba3f5563d727a66b
gh-108668: Preserve exception state during delegated throw #157235https://github.com/python/cpython/pull/157235
↩https://github.com/python/cpython/issues/108668#user-content-fnref-1-1ddfe715394f68abba3f5563d727a66b
gschaffnerhttps://github.com/gschaffner
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Aug 30, 2023https://github.com/python/cpython/issues/108668#event-10228748640
https://github.com/sobolevn
sobolevnhttps://github.com/sobolevn
on Aug 30, 2023https://github.com/python/cpython/issues/108668#issuecomment-1698597389
@iritkatrielhttps://github.com/iritkatriel
https://github.com/gschaffner
gschaffnerhttps://github.com/gschaffner
on Aug 30, 2023https://github.com/python/cpython/issues/108668#issuecomment-1698876385
GH-84871https://github.com/python/cpython/issues/84871
GH-84871https://github.com/python/cpython/issues/84871
#84871 (comment)https://github.com/python/cpython/issues/84871#issuecomment-1698844512
GH-84871https://github.com/python/cpython/issues/84871
1https://github.com/python/cpython/issues/108668#user-content-fn-1-089a8636fa833954791aac935131ec8e
GH-84871https://github.com/python/cpython/issues/84871
↩https://github.com/python/cpython/issues/108668#user-content-fnref-1-089a8636fa833954791aac935131ec8e
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Aug 30, 2023https://github.com/python/cpython/issues/108668#issuecomment-1699541140
https://github.com/iritkatriel
iritkatrielhttps://github.com/iritkatriel
on Aug 30, 2023https://github.com/python/cpython/issues/108668#issuecomment-1699704897
@gschaffnerhttps://github.com/gschaffner
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Aug 30, 2023https://github.com/python/cpython/issues/108668#issuecomment-1699898602
iritkatrielhttps://github.com/iritkatriel
on Aug 31, 2023https://github.com/python/cpython/issues/108668#event-10238458091
https://github.com/gschaffner
gschaffnerhttps://github.com/gschaffner
on Aug 31, 2023https://github.com/python/cpython/issues/108668#issuecomment-1700164320
picnixzhttps://github.com/picnixz
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
on Aug 13, 2026https://github.com/python/cpython/issues/108668#event-29416533024
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/108668
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/108668
iritkatrielhttps://github.com/iritkatriel
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.