Skip to content

bpo-43002: Fix description of behaviour of an exception class in 'from' clause #24303

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

Merged
merged 1 commit into from
Apr 11, 2021

Conversation

mdickinson
Copy link
Member

@mdickinson mdickinson commented Jan 23, 2021

In a raise <expr> from <expr2> statement, <expr2> is permitted to be an exception instance, an exception class, or None. The reference manual suggests that in the first two cases, the value of <expr2> is attached directly to the raise exception as the __cause__. But in the implementation, an exception class is first instantiated before being attached to the raised exception:

cpython/Python/ceval.c

Lines 4758 to 4763 in b745a61

if (PyExceptionClass_Check(cause)) {
fixed_cause = _PyObject_CallNoArg(cause);
if (fixed_cause == NULL)
goto raise_error;
Py_DECREF(cause);
}

This PR fixes the documentation to match the implementation.

https://bugs.python.org/issue43002

@cool-RR
Copy link
Contributor

cool-RR commented Jan 23, 2021

okay-but-its-5b256a

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 23, 2021
@mdickinson
Copy link
Member Author

This PR is stale because it has been open for 30 days with no activity.

Thanks, but I'm not quite sure what to do with this information.

Reviews are welcome. I'll plan to merge within the next couple of weeks.

@mdickinson mdickinson removed the stale Stale PR or inactive for long period of time. label Feb 26, 2021
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Mar 29, 2021
@mdickinson mdickinson merged commit 79650d0 into python:master Apr 11, 2021
@miss-islington
Copy link
Contributor

Thanks @mdickinson for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

@mdickinson mdickinson deleted the doc/exception-raise-from-class branch April 11, 2021 08:34
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 11, 2021
@bedevere-bot
Copy link

GH-25341 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Apr 11, 2021
@bedevere-bot
Copy link

GH-25342 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 11, 2021
mdickinson added a commit that referenced this pull request Apr 11, 2021
…H-24303) (GH-25342)

(cherry picked from commit 79650d0)

Co-authored-by: Mark Dickinson <[email protected]>

Co-authored-by: Mark Dickinson <[email protected]>
mdickinson added a commit that referenced this pull request Apr 11, 2021
…H-24303) (GH-25341)

(cherry picked from commit 79650d0)

Co-authored-by: Mark Dickinson <[email protected]>

Co-authored-by: Mark Dickinson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants