René's URL Explorer Experiment


Title: High-level outline of the first draft · Issue #2 · python/exceptiongroups · GitHub

Open Graph Title: High-level outline of the first draft · Issue #2 · python/exceptiongroups

X Title: High-level outline of the first draft · Issue #2 · python/exceptiongroups

Description: @njsmith @ambv feel free to edit this message. Introduction This should be a relatively high-level and fun to read section. Talk about exceptions in an abstract way. I.e. why it is important to have them in Python, why one of the key Pyt...

Open Graph Description: @njsmith @ambv feel free to edit this message. Introduction This should be a relatively high-level and fun to read section. Talk about exceptions in an abstract way. I.e. why it is important to hav...

X Description: @njsmith @ambv feel free to edit this message. Introduction This should be a relatively high-level and fun to read section. Talk about exceptions in an abstract way. I.e. why it is important to hav...

Opengraph URL: https://github.com/python/exceptiongroups/issues/2

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"High-level outline of the first draft","articleBody":"@njsmith @ambv feel free to edit this message.\r\n\r\n----------\r\n\r\n# Introduction\r\n\r\nThis should be a relatively high-level and fun to read section.\r\n\r\n- [ ] Talk about exceptions in an abstract way. I.e. why it is important to have them in Python, why one of the key Python design principle is that errors should never happen silently.\r\n\r\n- [ ] Why isn't one exception enough? Sometimes you have multiple errors that are all equally important:\r\n\r\n  * Main reason: Concurrency (async/await, threads, multiprocessing, ...): If you're doing multiple things at once, then multiple things can fail at once. Only options are to catch them, throw some away, or have some way to propagate multiple exceptions at once. We can't force users to catch them, so right now we have to throw them away, which breaks \"Errors should never pass silently\".\r\n\r\n  * Hypothesis runs a single test lots of times with random input. Sometimes it detects multiple distinct failures, on different inputs. Currently it has no good way to report that.\r\n\r\n  * A unit test: the test failed and also failed its tear down code.\r\n\r\n- [ ] Why aren't `__context__` and `__cause__` good enough? (They give more details about a single exception, but in these cases there are multiple independent errors, that need to be handled or propagated independently. Maybe a concrete example, e.g., you have both a network error + an assertion error, some routine retry code handles the network error, that shouldn't cause the assertion error to be lost?)\r\n\r\n# Motivation\r\n\r\nHere we should talk about exception groups in more detail explaining \"why\" and \"why now\".\r\n\r\n- [ ] Why we are looking at this problem now?  The answer is async/await.  Here we need to talk about `asyncio.gather()` and Trio/nurseries.\r\n\r\n  * `asyncio.gather(t1, t2, t3)` is the primitive one uses in asyncio to wait until multiple concurrent tasks are finished. It is flawed.  If `t1` is failed then we'd propagate its error and try to shutdown both `t2` and `t3`, but shutting them down can also result in errors. Those errors are currently lost.\r\n\r\n  * There's a `return_exceptions=True` flag for `asyncio.gather` that changes its behavior entirely. Exceptions are returned along with the results. This is a slightly better approach, but: it's an opt-in; handling exceptions this way is cumbersome -- you suddenly can't use `try..except` block.\r\n\r\n  * Controlling how things run concurrently is the key thing in asyncio. Current APIs are bad and we need a replacement ASAP.\r\n\r\n  * Trio has a concept called nurseries and it's great. This is what users want in asyncio—literally the most requested feature. Nurseries are context managers that let you structure your async code in a very visual and obvious way.\r\n\r\n  * The problem is that a nursery `with` block needs to propagate more than one exception. Boom, we need exception groups (**EG**) to implement them for asyncio.\r\n\r\n- [ ] To sum up: there were always use cases that required a concept like EGs. It's just that they were not as pronounced as they are now with async/await.\r\n\r\n- [ ] Why does it need to be in the language/stdlib? Can it be a third party library?\r\n\r\n  1. asyncio is in the stdlib, so everything asyncio uses has to be in the stdlib\r\n  2. Also, Trio tried that, and it kind of works but there's a lot of unfixable limitations:\r\n     - lots of basic exception stuff lives in stdlib, e.g. sys.excepthook needs to know about these, the traceback and logging modules need to know about these, etc.\r\n     - exceptions are often raised and caught in different pieces of code, e.g. pytest/ipython/sentry/ubuntu's [apport](https://wiki.ubuntu.com/Apport)/web frameworks/... all want to handle arbitrary exceptions and do something useful with them, so they and the async libraries all need to agree on how to represent these new objects. Ecosystem-wide coordination is what PEPs are for.\r\n     - Currently trio handles this by monkeypatching all the libraries it knows about...\r\n\r\n# What does an EG look like?\r\n\r\n- [ ] Summarize our answer: a concrete (final?) class `ExceptionGroup` that inherits from `BaseException`, and holds a list of exceptions + for each one an string tag giving some human-readable info about where this exception came from to enter this group. Show examples. Show nested examples.\r\n\r\nThen walk through the rationale for these choices:\r\n\r\n- [ ] The EG type must be an exception itself.  It cannot be a tuple or list.  Why: we want `try..finally` to work correctly when an exception group is propagated. Also, making `sys.exc_info()` / `PyThreadState-\u003eexc_info` start holding non-exception objects would be super invasive and probably break lots of things.\r\n\r\n- [ ] The EG type must be a `BaseException` as it can potentially contain multiple `BaseExceptions`.\r\n\r\n- [ ] To give useful tracebacks, we want to preserve the path the exception took, so these need to be nested (show an example of a Trio nested traceback to illustrate)\r\n\r\n- [ ] We want to attach tags / titles to exceptions within EGs. Tasks in asyncio/trio and threads in Python have names -- we want to attach a bit of information to every exception within a EG saying what's its origin.\r\n\r\n- [ ] But semantically, they represent an unstructured set of exceptions; we just use the tree structure to hold traceback info and to get a single object representing the set\r\n\r\n- [ ] Discuss why we allow single-element `ExceptionGroup`s\r\n\r\n  - [ ] Gives opportunity to attach tags to show which tasks an exception passed through as it propagated\r\n\r\n  - [ ] In current prototypes, catching exceptions inside an `ExceptionGroup` requires special ceremony. If this ceremony is needed *sometimes*, then we want to make it needed *always*, so that users don't accidentally use regular `try`/`except` and have it seem to work until they get unlucky and multiple exceptions happen at the same time. Therefore, exceptions that pass through a Trio nursery/asyncio `TaskGroup` should be unconditionally wrapped in an `ExceptionGroup`. But, this rationale may or may not apply to a \"native\" version of `ExceptionGroup`s, depending on what design we end up with for catching them.\r\n\r\n# Working with exception groups\r\n\r\n- [ ] Core primitives: `split` and `leaves`\r\n\r\n- [ ] Semantics\r\n\r\n- [ ] Rationale\r\n\r\n# Catching exceptions in `ExceptionGroups`\r\n\r\n- [ ] Explain basic desired semantics: can have multiple handler \"arms\", multiple arms can match the same group, they're executed in sequence, then any unhandled exceptions + new exceptions are bundled up into a new `ExceptionGroup`\r\n\r\n- [ ] How should this be spelled? We're not sure. Trade-offs are *extremely* messy; we're not even going to try doing a full discussion in this first draft. Some options we see:\r\n\r\n  * Modifying the behavior of `try..except` to have these semantics. (Downside: major change to the language!)\r\n\r\n  * Leave `try`/`except` alone, add new syntax (`grouptry`/`groupexcept` or whatever). (Downside: you always want `grouptry`/`groupexcept`, never `try`/`except`!)\r\n\r\n  * No new syntax, use awkward circumlocutions instead of `try`/`except`. (Downside: they're extremely awkward!)\r\n\r\nSince the design space and trade-offs are *super* complex, we're leaving a full discussion for a later draft / follow-up PEP.","author":{"url":"https://github.com/1st1","@type":"Person","name":"1st1"},"datePublished":"2019-12-16T20:34:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/2/exceptiongroups/issues/2"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:639c14f3-ba73-a321-8f21-1baad0d61727
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id935E:21FEDA:4DF1F0:6CD4BE:696A7808
html-safe-nonce79c6f8e9811f73b161bfcffda9e2b3304636ff4d8ae408047cf4e450feb93a02
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzVFOjIxRkVEQTo0REYxRjA6NkNENEJFOjY5NkE3ODA4IiwidmlzaXRvcl9pZCI6IjYyODkwODk5OTg3NzQ0OTkzMzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacdb810892c129f9a682fdf0abbb04d41c00469f3ac38bef737d9a4b6ce6a55c4e
hovercard-subject-tagissue:538639546
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/exceptiongroups/2/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6ec282d971f19d267e1e24c735527fe975ff717539f39941f0bfb95ece132b7b/python/exceptiongroups/issues/2
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6ec282d971f19d267e1e24c735527fe975ff717539f39941f0bfb95ece132b7b/python/exceptiongroups/issues/2
og:image:alt@njsmith @ambv feel free to edit this message. Introduction This should be a relatively high-level and fun to read section. Talk about exceptions in an abstract way. I.e. why it is important to hav...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:username1st1
hostnamegithub.com
expected-hostnamegithub.com
None5b774e44f85c14a75886edd04ddda4e5a25ddebbb241bcbb590b08a3048730e8
turbo-cache-controlno-preview
go-importgithub.com/python/exceptiongroups git https://github.com/python/exceptiongroups.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id228462148
octolytics-dimension-repository_nwopython/exceptiongroups
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id228462148
octolytics-dimension-repository_network_root_nwopython/exceptiongroups
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
releasecc5f4eee261b3601c1e98e217ceaf28508b9567e
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/exceptiongroups/issues/2#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fexceptiongroups%2Fissues%2F2
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fexceptiongroups%2Fissues%2F2
Sign up https://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%2Fexceptiongroups
Reloadhttps://github.com/python/exceptiongroups/issues/2
Reloadhttps://github.com/python/exceptiongroups/issues/2
Reloadhttps://github.com/python/exceptiongroups/issues/2
python https://github.com/python
exceptiongroupshttps://github.com/python/exceptiongroups
Notifications https://github.com/login?return_to=%2Fpython%2Fexceptiongroups
Fork 2 https://github.com/login?return_to=%2Fpython%2Fexceptiongroups
Star 21 https://github.com/login?return_to=%2Fpython%2Fexceptiongroups
Code https://github.com/python/exceptiongroups
Issues 2 https://github.com/python/exceptiongroups/issues
Pull requests 0 https://github.com/python/exceptiongroups/pulls
Actions https://github.com/python/exceptiongroups/actions
Projects 0 https://github.com/python/exceptiongroups/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/exceptiongroups/security
Please reload this pagehttps://github.com/python/exceptiongroups/issues/2
Insights https://github.com/python/exceptiongroups/pulse
Code https://github.com/python/exceptiongroups
Issues https://github.com/python/exceptiongroups/issues
Pull requests https://github.com/python/exceptiongroups/pulls
Actions https://github.com/python/exceptiongroups/actions
Projects https://github.com/python/exceptiongroups/projects
Security https://github.com/python/exceptiongroups/security
Insights https://github.com/python/exceptiongroups/pulse
High-level outline of the first drafthttps://github.com/python/exceptiongroups/issues/2#top
https://github.com/1st1
https://github.com/1st1
1st1https://github.com/1st1
on Dec 16, 2019https://github.com/python/exceptiongroups/issues/2#issue-538639546
@njsmithhttps://github.com/njsmith
@ambvhttps://github.com/ambv
apporthttps://wiki.ubuntu.com/Apport
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.