Skip to content
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

bpo-37502: handle default parameter for buffers argument of pickle.loads #14593

Merged
merged 1 commit into from
Jul 25, 2019

Conversation

mmohrhard
Copy link
Contributor

@mmohrhard mmohrhard commented Jul 5, 2019

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

Copy link
Contributor

@aeros aeros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmohrhard Thanks for the contribution! For verification of the bug described in https://bugs.python.org/issue37502, I ran pickle.loads(pickle.dumps(1, protocol=pickle.HIGHEST_PROTOCOL), buffers=None) in the interpreter after installing the latest version of python:master:

image

To test this PR, I installed the branch mmohrhard:buffer-default-in-pickle-loads and ran the same code as above in the interpreter:

image

As can be seen from the screenshots above, TypeError is no longer raised when buffers is set to None.

Edit: I would recommend replacing the news blurb to be a bit more descriptive, to specify the exception.

Currently it is:

Fix error when buffer argument of pickle.loads is None

I would recommend changing the phrasing to:

pickle.loads() no longer raises TypeError when the buffers argument is set to None

@mmohrhard mmohrhard force-pushed the buffer-default-in-pickle-loads branch from a411622 to 9ac140a Compare July 9, 2019 10:34
@mmohrhard
Copy link
Contributor Author

@aeros167 Thanks. I have updated the patch set with your suggest text for the news blurb and squashed the commits.

Please let me know if there is anything else that I should do.

@brettcannon brettcannon added the type-feature A feature request or enhancement label Jul 11, 2019
@@ -1653,7 +1653,7 @@ _Unpickler_SetInputEncoding(UnpicklerObject *self,
static int
_Unpickler_SetBuffers(UnpicklerObject *self, PyObject *buffers)
{
if (buffers == NULL) {
if (buffers == NULL || buffers == Py_None) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Propagating down 2 special values meaning "no buffers" is ugly. Can we
normalize the value when we parse the arguments, so the rest of the code
have exactly one value for "no buffers"?

@zware zware requested a review from pitrou July 25, 2019 15:49
@pitrou pitrou added needs backport to 3.8 type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Jul 25, 2019
Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this. This looks good to me.

@pitrou pitrou merged commit 898318b into python:master Jul 25, 2019
@miss-islington
Copy link
Contributor

Thanks @mmohrhard for the PR, and @pitrou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-14948 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 25, 2019
…ads correctly (pythonGH-14593)

(cherry picked from commit 898318b)

Co-authored-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
miss-islington added a commit that referenced this pull request Jul 25, 2019
…ads correctly (GH-14593)

(cherry picked from commit 898318b)

Co-authored-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants