-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-105375: Improve error handling in _Unpickler_SetInputStream() #105667
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
gh-105375: Improve error handling in _Unpickler_SetInputStream() #105667
Conversation
Prevent exceptions from possibly being overwritten in case of multiple failures.
@serhiy-storchaka, would you have time to look at this bugfix? |
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 you missed the purpose _PyObject_LookupAttr()
. It was designed to get rid of PyErr_ExceptionMatches(PyExc_AttributeError)
checks and the overhead of raising and catching an exception.
- There's no need to match AttributeError, since _PyObject_LookupAttr() converts that exception into a return value of 0. - We can use the result output variable instead of adding temporary boolean indicators.
Don't clear arbitrary exceptions
There's no need for PyErr_Occurred() anymore
Thanks for the very helpful review and historical insight, Serhiy. |
Thanks @erlend-aasland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
GH-105720 is a backport of this pull request to the 3.12 branch. |
GH-105721 is a backport of this pull request to the 3.11 branch. |
…Stream() (python#105667) Prevent exceptions from possibly being overwritten in case of multiple failures. (cherry picked from commit 217589d) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
…Stream() (python#105667) Prevent exceptions from possibly being overwritten in case of multiple failures. (cherry picked from commit 217589d) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Prevent exceptions from possibly being overwritten in case of multiple
failures.