-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
gh-141749: fix incorrect exceptions in pure Python Unpickler #141751
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
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
| assert isinstance(key, bytes_types) | ||
| dispatch[key[0]](self) | ||
| try: | ||
| dispatch[key[0]](self) |
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.
Do not catch a KeyError for the call. Use a temporary variable for the dispatcher first.
|
|
||
| unpickler = pickle._Unpickler | ||
| bad_stack_errors = (IndexError,) | ||
| bad_stack_errors = (IndexError, pickle.UnpicklingError) |
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.
Shpuld we still catch IndexError now?
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
Ah I didn't that we had a second PR for that by the OP. Usually it is polite to ask the OP if they want to make a PR before making it one, and they did so a bit after. In this case I am actually going to close this one. Sorry. |
Fixed incorrect exception types occurring in the CPython
Unpicklerimplementation when loading invalid pickle data. In some cases, the CPython fallback raised internalKeyErrorandIndexErrorexceptions instead ofUnpicklingError.This PR adds correct error handling in both places so that UnpicklingError is raised consistently.