diff options
author | Paul Ganssle <pganssle@users.noreply.github.com> | 2019-02-04 19:42:04 (GMT) |
---|---|---|
committer | Alexander Belopolsky <abalkin@users.noreply.github.com> | 2019-02-04 19:42:04 (GMT) |
commit | 89427cd0feae25bbc8693abdccfa6a8c81a2689c (patch) | |
tree | c08a1bb264e74eec38f488fa60c3889fae424f2c /Misc | |
parent | ca7d2933a388677cc3bbc621913b479452c0f25a (diff) | |
download | cpython-89427cd0feae25bbc8693abdccfa6a8c81a2689c.zip cpython-89427cd0feae25bbc8693abdccfa6a8c81a2689c.tar.gz cpython-89427cd0feae25bbc8693abdccfa6a8c81a2689c.tar.bz2 |
bpo-32417: Make timedelta arithmetic respect subclasses (#10902)
* Make timedelta return subclass types
Previously timedelta would always return the `date` and `datetime`
types, regardless of what it is added to. This makes it return
an object of the type it was added to.
* Add tests for timedelta arithmetic on subclasses
* Make pure python timedelta return subclass types
* Add test for fromtimestamp with tz argument
* Add tests for subclass behavior in now
* Add news entry.
Fixes:
bpo-32417
bpo-35364
* More descriptive variable names in tests
Addresses Victor's comments
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Library/2018-12-04-13-35-36.bpo-32417._Y9SKM.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2018-12-04-13-35-36.bpo-32417._Y9SKM.rst b/Misc/NEWS.d/next/Library/2018-12-04-13-35-36.bpo-32417._Y9SKM.rst new file mode 100644 index 0000000..cfc4fbe --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-12-04-13-35-36.bpo-32417._Y9SKM.rst @@ -0,0 +1,6 @@ +Performing arithmetic between :class:`datetime.datetime` subclasses and +:class:`datetime.timedelta` now returns an object of the same type as the +:class:`datetime.datetime` subclass. As a result, +:meth:`datetime.datetime.astimezone` and alternate constructors like +:meth:`datetime.datetime.now` and :meth:`datetime.fromtimestamp` called with +a ``tz`` argument now *also* retain their subclass. |