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-37372: Fix unpickling certain datetime.time objects from Python 2 #14307

Merged
merged 4 commits into from Aug 29, 2019

Conversation

UncombedCoconut
Copy link
Contributor

@UncombedCoconut UncombedCoconut commented Jun 22, 2019

Fix for: https://bugs.python.org/issue37372 "datetime.time unpickling fails in case of python2 pickle with seconds>=24". Thanks!

https://bugs.python.org/issue37372

@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).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

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

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

@tirkarthi
Copy link
Member

Does this PR change the old tests to validate this fix? I think it's good to have new tests than modifying existing tests to catch regressions.

@UncombedCoconut
Copy link
Contributor Author

Does this PR change the old tests to validate this fix? I think it's good to have new tests than modifying existing tests to catch regressions.

That's right, thanks for clarifying the preferred way to update tests. Do you have strong views on what the tests should be "about"? A test on the specific bug seems too niche, and the existing tests' structure doesn't invite a new input/assertion pair, but maybe a slightly broader test on the inputs' limits...

@pganssle
Copy link
Member

A test on the specific bug seems too niche, and the existing tests' structure doesn't invite a new input/assertion pair, but maybe a slightly broader test on the inputs' limits...

I think it's fine to add a test for the specific bug. It makes it a lot easier to see just from running the test suite what kind of regression you are getting.

Maybe in this case the right thing to do is to parametrize over both expected input and expected output, e.g.:

tests = [
    (b"cdatetime\ntime\n(S'\\x14;\\x10\\x00\\x10\\x00'\ntR.", (20, 59, 16, 64**2)),'
    ...
    (b"cdatetime\ntime\n(S'\\x14;\\x19\\x00\\x10\\x00'\ntR.", (20, 59, 25, 64**2)),'
]

I also think it would be prudent to add a with self.subTest context manager in the test, so that each of the entries can fail independently.

@UncombedCoconut
Copy link
Contributor Author

A test on the specific bug seems too niche, and the existing tests' structure doesn't invite a new input/assertion pair, but maybe a slightly broader test on the inputs' limits...

I think it's fine to add a test for the specific bug. It makes it a lot easier to see just from running the test suite what kind of regression you are getting.

Maybe in this case the right thing to do is to parametrize over both expected input and expected output, e.g.:

tests = [
    (b"cdatetime\ntime\n(S'\\x14;\\x10\\x00\\x10\\x00'\ntR.", (20, 59, 16, 64**2)),'
    ...
    (b"cdatetime\ntime\n(S'\\x14;\\x19\\x00\\x10\\x00'\ntR.", (20, 59, 25, 64**2)),'
]

I also think it would be prudent to add a with self.subTest context manager in the test, so that each of the entries can fail independently.

Good idea, thanks. I'll give it a go.

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.

Good catch! The PR LGTM, but please add more details in a news entry and add your credits.

@@ -0,0 +1 @@
Fix errors unpickling certain datetime.time objects from Python 2.
Copy link
Member

Choose a reason for hiding this comment

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

Please add a little more details: "with minutes or seconds >= 24".

Add also "Patch by Justin Blanchard." here and add your name in Misc/ACKS.

@pganssle
Copy link
Member

I don't see any more objections (though I don't understand the C part of the code so I'm not going to submit a formal review). @serhiy-storchaka feel free to merge if you were waiting on me.

@UncombedCoconut
Copy link
Contributor Author

I don't see any more objections (though I don't understand the C part of the code so I'm not going to submit a formal review). @serhiy-storchaka feel free to merge if you were waiting on me.

Thank you very much for your help!

@ned-deily
Copy link
Member

@serhiy-storchaka, @pganssle This PR seems to have stalled. Are you planning to merge it?

@serhiy-storchaka serhiy-storchaka merged commit 122376d into python:master Aug 29, 2019
@serhiy-storchaka serhiy-storchaka added needs backport to 3.7 needs backport to 3.8 only security fixes type-bug An unexpected behavior, bug, or error labels Aug 29, 2019
@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

Thanks @UncombedCoconut for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 29, 2019
…ith seconds>=24. (pythonGH-14307)

(cherry picked from commit 122376d)

Co-authored-by: Justin Blanchard <UncombedCoconut@gmail.com>
@bedevere-bot
Copy link

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

@bedevere-bot
Copy link

GH-15584 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 29, 2019
…ith seconds>=24. (pythonGH-14307)

(cherry picked from commit 122376d)

Co-authored-by: Justin Blanchard <UncombedCoconut@gmail.com>
miss-islington added a commit that referenced this pull request Aug 29, 2019
…ith seconds>=24. (GH-14307)

(cherry picked from commit 122376d)

Co-authored-by: Justin Blanchard <UncombedCoconut@gmail.com>
miss-islington added a commit that referenced this pull request Aug 29, 2019
…ith seconds>=24. (GH-14307)

(cherry picked from commit 122376d)

Co-authored-by: Justin Blanchard <UncombedCoconut@gmail.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.

None yet

8 participants