-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Tutorial's claim about default exception chaining misleading #97654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It is a tutorial, not the reference manual. It doesn't have to dive deep into every facet of the feature. As you say yourself, it "is true" that exceptions are chained automatically, exactly as the tutorial says. I take your point about the (very slight) difference in intended semantics of the two situations, but they aren't two different kinds of chaining. There is only one kind of exception chaining, which differ only in whether the link between one exception and the other is described as a cause or not. Since the chain can be an arbitrary number of exceptions long, it can contain an arbitrary mix of exceptions with the cause or the context set.
"Extremely" misleading? Over a slight difference in wording, that most people will neither notice nor care about? I don't think it is misleading at all, let alone "extremely" misleading. I think that dealing with this subtle difference as part of the tutorial is unnecessary detail for the tutorial's intended audience. |
@stevendaprano So why have Maybe another way to approach this would be to first have a paragraph either in that section or in an earlier one that shows what happens normally when an exception is raised from inside an |
Add auto exception chaining example to tutorial
…onGH-97703) Add auto exception chaining example to tutorial (cherry picked from commit 395b66a) Co-authored-by: Shahriar Heidrich <[email protected]>
…onGH-97703) Add auto exception chaining example to tutorial (cherry picked from commit 395b66a) Co-authored-by: Shahriar Heidrich <[email protected]>
…97703) (#97884) Add auto exception chaining example to tutorial (cherry picked from commit 395b66a) Co-authored-by: Shahriar Heidrich <[email protected]>
Backports were merged, thank you! |
…on#97703) Add auto exception chaining example to tutorial
Documentation
The tutorial's section on exception chaining (
raise x from y
) currently claims:While that is true, the semantics of automatically chained exceptions are different from ones explicitly chained with
from
, which is also reflected in how their relation is described in the resulting error messages: Automatically chained exceptions are linked withwhile for explicitly chained exceptions it says
That is not mentioned anywhere in the tutorial section, making the claim that "chaining happens automatically" by itself extremely misleading because it suggests to people they'll get the same result whether they chain explicitly with
from
or not, which isn't the case. It's probably also confusing to those readers who give it a bit more thought, because the natural question to ask would be "Then why doesfrom
exist at all if it happens automatically anyway?"My suggestion would be to explain the semantic difference and the different resulting outputs in the tutorial section, e.g. like this:
Of course the phrasing isn't perfect but that can be fought over in a PR if you think the overall point of this issue is valid.
Related issues
__cause__
vs__context__
, should be explained.The text was updated successfully, but these errors were encountered: