Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-122311: Fix some error messages in pickle#122386
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
serhiy-storchaka merged 1 commit intopython:mainfromserhiy-storchaka:pickle-error-messagesJul 29, 2024
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
gh-122311: Fix some error messages in pickle
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitd7d8ba35ed344fe306d083a204c0ee0193bd0f4f
There are no files selected for viewing
7 changes: 4 additions & 3 deletionsLib/pickle.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -314,16 +314,17 @@ def load_frame(self, frame_size): | ||
| # Tools used for pickling. | ||
| def _getattribute(obj, name): | ||
| top = obj | ||
| for subpath in name.split('.'): | ||
| if subpath == '<locals>': | ||
| raise AttributeError("Can't get local attribute {!r} on {!r}" | ||
| .format(name,top)) | ||
picnixz marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| try: | ||
| parent = obj | ||
| obj = getattr(obj, subpath) | ||
| except AttributeError: | ||
| raise AttributeError("Can't get attribute {!r} on {!r}" | ||
| .format(name,top)) from None | ||
| return obj, parent | ||
| def whichmodule(obj, name): | ||
| @@ -832,7 +833,7 @@ def save_bytearray(self, obj): | ||
| if _HAVE_PICKLE_BUFFER: | ||
| def save_picklebuffer(self, obj): | ||
| if self.proto < 5: | ||
| raise PicklingError("PickleBuffer can onlybepickled with " | ||
| "protocol >= 5") | ||
| with obj.raw() as m: | ||
| if not m.contiguous: | ||
4 changes: 3 additions & 1 deletionLib/test/pickletester.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1982,8 +1982,10 @@ def test_picklebuffer_error(self): | ||
| pb = pickle.PickleBuffer(b"foobar") | ||
| for proto in range(0, 5): | ||
| with self.subTest(proto=proto): | ||
| with self.assertRaises(pickle.PickleError) as cm: | ||
| self.dumps(pb, proto) | ||
| self.assertEqual(str(cm.exception), | ||
| 'PickleBuffer can only be pickled with protocol >= 5') | ||
picnixz marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| def test_non_continuous_buffer(self): | ||
| if self.pickler is pickle._Pickler: | ||
1 change: 1 addition & 0 deletionsMisc/NEWS.d/next/Library/2024-07-29-10-24-48.gh-issue-122311.xChV1b.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix some error messages in :mod:`pickle`. |
6 changes: 3 additions & 3 deletionsModules/_pickle.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.