-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-140530: fix a reference leak in an error path for raise exc from cause
#140908
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix a reference leak when ``raise exc from cause`` fails. Patch by Bénédikt | ||
| Tran. |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2148,6 +2148,7 @@ do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause) | |||||||||
| "calling %R should have returned an instance of " | ||||||||||
| "BaseException, not %R", | ||||||||||
| cause, Py_TYPE(fixed_cause)); | ||||||||||
| Py_DECREF(fixed_cause); | ||||||||||
| goto raise_error; | ||||||||||
| } | ||||||||||
| Py_DECREF(cause); | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checking so I'm clear:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIR, yes.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, Lines 548 to 551 in 7ae440f
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the old test and add the new test in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old test is actually testing the same code. The problem was that the returned value was immortal...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR:
Since
causeis an exception class, we called__new__andfixed_causewould have beenNone. We would then move toPyExceptionInstance_Checkbut sincefixed_causeis immortal the refleak didn't appear.