Skip to content

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

Merged

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Jun 11, 2023

Prevent exceptions from possibly being overwritten in case of multiple
failures.

Prevent exceptions from possibly being overwritten in case of multiple
failures.
@erlend-aasland
Copy link
Contributor Author

@serhiy-storchaka, would you have time to look at this bugfix?

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a 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
@erlend-aasland
Copy link
Contributor Author

Thanks for the very helpful review and historical insight, Serhiy.

@miss-islington
Copy link
Contributor

Thanks @erlend-aasland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@erlend-aasland erlend-aasland deleted the improve-pickle-error-handling branch June 13, 2023 08:38
@bedevere-bot
Copy link

GH-105720 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jun 13, 2023
@bedevere-bot
Copy link

GH-105721 is a backport of this pull request to the 3.11 branch.

erlend-aasland added a commit to erlend-aasland/cpython that referenced this pull request Jun 13, 2023
…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>
erlend-aasland added a commit to erlend-aasland/cpython that referenced this pull request Jun 13, 2023
…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>
@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jun 13, 2023
erlend-aasland added a commit that referenced this pull request Jun 13, 2023
…() (#105667) (#105721)

Prevent exceptions from possibly being overwritten in case of multiple
failures.

(cherry picked from commit 217589d)
erlend-aasland added a commit that referenced this pull request Jun 13, 2023
…() (#105667) (#105720)

Prevent exceptions from possibly being overwritten in case of multiple
failures.

(cherry picked from commit 217589d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants