]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-24416: Return named tuple from date.isocalendar() (GH-20113)
authorPaul Ganssle <paul@ganssle.io>
Sat, 16 May 2020 14:02:59 +0000 (10:02 -0400)
committerGitHub <noreply@github.com>
Sat, 16 May 2020 14:02:59 +0000 (10:02 -0400)
commit1b97b9b0ad9a2ff8eb5c8f2e2e7c2aec1d13a330
treee4e0db3789e402a65ad817f0a17375b756d3e251
parentaa92a7cf210c98ad94229f282221136d846942db
bpo-24416: Return named tuple from date.isocalendar() (GH-20113)

{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>
Doc/library/datetime.rst
Doc/whatsnew/3.9.rst
Lib/datetime.py
Lib/test/datetimetester.py
Misc/NEWS.d/next/Library/2019-09-01-15-17-49.bpo-24416.G8Ww1U.rst [new file with mode: 0644]
Modules/_datetimemodule.c
Modules/clinic/_datetimemodule.c.h