Fix DST arithmetic issues introduced as a side effect of python 3.8 change https://bugs.python.org/issue32417 - #28
Merged
micolous merged 4 commits intoNov 4, 2020
Conversation
Merge upstream master 0.5
…ling Bring master up to date with upstream, then Improve windows territory handling
Update the j5int fork to the latest master from mithro
….8 changed the datetime arithmetic functions to return instances of the same class as the instance, instead of new datetime.datetime instances. See the "What's new notes": Arithmetic operations between subclasses of datetime.date or datetime.datetime and datetime.timedelta objects now return an instance of the subclass, rather than the base class. This also affects the return type of operations whose implementation (directly or indirectly) uses datetime.timedelta arithmetic, such as astimezone(). (Contributed by Paul Ganssle in bpo-32417.) Unfortunately, the side-effect of this change was to end up calling datetime_tz.__new__ with the set of arguments that result in tzinfo.localize being called on the result instead of tzinfo.normalize. This changed the resulting answer, in particular where DST transitions were involved. The testAroundDst were failing with python 3.8 before this change. The fix makes it behave in the same way as it did before - where a datetime.datetime object is return from the arithmetic result and then passed to the datetime_tz constructor. The other functions that do something similar work in the same way (e.g. astimezone).
Collaborator
|
Thanks! |
This file contains hidden or 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
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.
Changes introduced in https://bugs.python.org/issue32417 for python 3.8 changed the datetime arithmetic functions to return instances of the same class as the instance, instead of new datetime.datetime instances.
See the "What's new notes":
Arithmetic operations between subclasses of datetime.date or datetime.datetime and datetime.timedelta objects now return an instance of the subclass, rather than the base class. This also affects the return type of operations whose implementation (directly or indirectly) uses datetime.timedelta arithmetic, such as astimezone(). (Contributed by Paul Ganssle in bpo-32417.)
Unfortunately, the side-effect of this change was to end up calling
datetime_tz.__new__with the set of arguments that result intzinfo.localizebeing called on the result instead oftzinfo.normalize. This changed the resulting answer, in particular where DST transitions were involved. ThetestAroundDstwere failing with python 3.8 before this change.The fix makes it behave in the same way as it did before - where a datetime.datetime object is return from the arithmetic result and then passed to the datetime_tz constructor.
The other functions that do something similar work in the same way (e.g. astimezone).