Title: Subclasses of `ExceptionGroup` can wrap `BaseException`s · Issue #99553 · python/cpython · GitHub
Open Graph Title: Subclasses of `ExceptionGroup` can wrap `BaseException`s · Issue #99553 · python/cpython
X Title: Subclasses of `ExceptionGroup` can wrap `BaseException`s · Issue #99553 · python/cpython
Description: class MyEG(ExceptionGroup): """Holds BaseExceptions without itself being a BaseException.""" oops = MyEG("oops", [KeyboardInterrupt()]) assert isinstance(oops, Exception) assert not isinstance(oops.exceptions[0], Exception) I believe tha...
Open Graph Description: class MyEG(ExceptionGroup): """Holds BaseExceptions without itself being a BaseException.""" oops = MyEG("oops", [KeyboardInterrupt()]) assert isinstance(oops, Exception) assert not isinstance(oops...
X Description: class MyEG(ExceptionGroup): """Holds BaseExceptions without itself being a BaseException.""" oops = MyEG("oops", [KeyboardInterrupt()]) assert isinstance(oop...
Opengraph URL: https://github.com/python/cpython/issues/99553
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Subclasses of `ExceptionGroup` can wrap `BaseException`s","articleBody":"```python\r\nclass MyEG(ExceptionGroup):\r\n \"\"\"Holds BaseExceptions without itself being a BaseException.\"\"\"\r\n\r\noops = MyEG(\"oops\", [KeyboardInterrupt()])\r\nassert isinstance(oops, Exception)\r\nassert not isinstance(oops.exceptions[0], Exception)\r\n```\r\n\r\nI believe that this is a bug tracing to the period when PEP-654 did not intend `(Base)ExceptionGroup` to be usable as a parent class; and I think a sufficient fix would be to replace the type-equality check with an isinstance check in:\r\n\r\nhttps://github.com/python/cpython/blob/bc390dd93574c3c6773958c6a7e68adc83d0bf3f/Objects/exceptions.c#L740-L744\r\n\r\ncc @iritkatriel; raised via https://github.com/agronholm/exceptiongroup/pull/40#discussion_r1020961107\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-99572\n* gh-99580\n* gh-99615\n* gh-103435\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/Zac-HD","@type":"Person","name":"Zac-HD"},"datePublished":"2022-11-17T00:09:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/99553/cpython/issues/99553"}
| 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:ac3923fb-d60b-4ac5-e484-4e046102c481 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B452:2F31CD:CF5CDD:11E1FA7:6969F579 |
| html-safe-nonce | 6b51d06186f837635b4cc95a02daf73b14c5bae2451b89851f9510b54700aae1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDUyOjJGMzFDRDpDRjVDREQ6MTFFMUZBNzo2OTY5RjU3OSIsInZpc2l0b3JfaWQiOiI3MDE3NDQxMjY0NDc4NTgyMTM3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a85898a5db7d315a7c37db4f9e92c88b7059d87b5782967553c4619b2098ffff |
| hovercard-subject-tag | issue:1452477287 |
| 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/99553/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5f5160f30a7f78ac284325bd84522ea72a64c5b872eb9e0f241076222c8f3483/python/cpython/issues/99553 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5f5160f30a7f78ac284325bd84522ea72a64c5b872eb9e0f241076222c8f3483/python/cpython/issues/99553 |
| og:image:alt | class MyEG(ExceptionGroup): """Holds BaseExceptions without itself being a BaseException.""" oops = MyEG("oops", [KeyboardInterrupt()]) assert isinstance(oops, Exception) assert not isinstance(oops... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Zac-HD |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| 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 | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width