-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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-24416: Return IsoCalendarDate from date.isocalendar() #20113
Merged
Conversation
This file contains 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
bpo-24416: Apply code review bpo-24416: Apply code review bpo-24416: Update docstrings bpo-24416: Apply third's codereview bpo-24416: Revert to support pickle bpo-24416: Update misc/news bpo-24416: Update __new__ Change pickling behavior of isocalendar() objects In order to leave IsocalendarDate as a private class and to improve what backwards compatibility is offered for pickling the result of a datetime.isocalendar() call, add a __reduce__ method to the named tuples that reduces them to plain tuples. Also add a test to this effect. Rename IsoCalendarDate to _IsoCalendarDate bpo-24416: Update datetime.rst bpo-24416: Update unittest Revert "Rename IsoCalendarDate to _IsoCalendarDate" This reverts commit 448a2109dfde1558a082de78171d17580995a950. Revert "Change pickling behavior of isocalendar() objects" This reverts commit 104264121ea49795da87fc803a270bdda8fa21d2. bpo-24416: Add pickle test bpo-24416: Update C API to subclass tuple bpo-24416: Change pickling behavior of isocalendar() objects bpo-24416: Update __new__ bpo-24416: Update whatsnew bpo-24416: Apply vstinner's review
This is only constructed internally and doesn't use keyword arguments. The equivalent change in the argument clinic on the C side would require us to move the forward declaration of the type above the clinic import for whatever reason, so it seems preferable to hold off on that for now.
corona10
approved these changes
May 15, 2020
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.
LGTM
Thanks @corona10! |
arturoescaip
pushed a commit
to arturoescaip/cpython
that referenced
this pull request
May 24, 2020
{date, datetime}.isocalendar() now return a private custom named tuple object IsoCalendarDate rather than a simple tuple. In order to leave IsocalendarDate as a private class and to improve what backwards compatibility is offered for pickling the result of a datetime.isocalendar() call, add a __reduce__ method to the named tuples that reduces them to plain tuples. (This is the part of this PR most likely to cause problems — if it causes major issues, switching to a strucseq or equivalent would be prudent). The pure python implementation of IsoCalendarDate uses positional-only arguments, since it is private and only constructed by position anyway; the equivalent change in the argument clinic on the C side would require us to move the forward declaration of the type above the clinic import for whatever reason, so it seems preferable to hold off on that for now. bpo-24416: https://bugs.python.org/issue24416 Original PR by Dong-hee Na with only minor alterations by Paul Ganssle. Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a repackaging of #15633, because the history there got into conflict with
master
and handling a bunch of rebase conflicts when rebasing and maintaining history was too much work. Instead, I've squashed #15633 and added my own modifications on top.I think this is more or less ready to merge, and I'd like to see it in for beta 1 of Python 3.9.
I can't really recall why
datetime.IsoCalendarDate
was public in the C extension in the current version of #15633, and nothing seems to go wrong if I remove it from the module, so I've gone ahead and done that.@corona10 Mind taking a look?
https://bugs.python.org/issue24416