Backport zoneinfo logic into dateutil.tz.tzfile#1130
Conversation
|
@pganssle do you want me to review this? |
|
@mariocj89 I still need to backport the tests, but you are welcome to review it. I expect in the long run we'll want to consolidate some of the logic around Also I believe some documentation changes will be necessary before we can merge this as well. |
|
OK, I'll take a look once all is ready. |
|
So @mariocj89 I suppose this is really the only remaining blocker for dropping support for Python 2? Dropping support for Python 2 would mean we could get into in-place typing info and all the new fun stuff right :)? Given this has been open for ages, should I try to prioritize this MR, open a new MR and see if we can get somewhere within the next few months? |
|
+1 |
|
Hi @mariocj89,
|
Without this change users in 2.7 will not get tz upgrades. This splits the tzdata from the package, allowing users to stay in an old version of the package but still get tzdata upgrades.
Correct
Needs to work for py2, so no type hints :). |
Now it completely makes sense! Thanks. |
|
@mariocj89 to improve visibility on the progress & smoothen the process a little. Can we open a new branch containing this work so far? I was diving a bit further (as I want to make sure I understand the full context before making changes) and was wondering the following: |
|
@pganssle are you still actively working on getting this change merged? |
|
Unfortunately I don't have the time anymore to work on this and made zero progress anyway. So I don't think anyone is working on this. The code is very complex and you are only doing this for python 2 users. Given that reached end of life years ago, I'm not to enthusiastic to work on this anyway. |
24c8f99 to
4d4bafa
Compare
06dd279 to
e362489
Compare
This creates a fictional time zone Fictional/Liliput (a copy of Arctic/Longyearbyne) and puts it in a temporary directory that is used as the TZPATH, then we ensure that we can load the result.
This essentially backports the tests from the `zoneinfo` test suite.
We were building with fat because dateutil did not support the default (slim), but now it does, so we can switch to slim. It might make sense to run the tests with both fat and slim, but I am not convinced that it would be worth it.
Summary of changes
This moves
tzfileinto its own submodule containing what is effectively a backport of the pure python implementation ofzoneinfo.ZoneInfo, but with the semantics of adateutil.tz.tzfileobject.The major differences from zoneinfo are:
tz.gettzrather than intz.tzfile.tzfileobjects are pickled by value, not by reference to the IANA key.tzfilehas equality-by-value semantics, whereaszoneinfohas equality-by-identity semantics.This does change the internal implementation details of the class. It also fixes at least two bugs:
dateutildid not use thefoldattribute during gaps (only during folds), in violation of PEP 495. This fixes that, but that does change the semantics of imaginary times a bit (and thus may affect some mechanisms for detecting imaginary times).This is mostly a code dump with compatibility adjustments. It's quite possible that we'll want to refactor, particularly with respect to the way POSIX strings are handled. Theoretically
tzfilecould fall back to atz.tzstror some othertz.tzrange, or we could refactortzstrandtzrangein terms of _CalendarOffset, _DayOffset and _TZStr (or both, by refactoring the internal logic oftzstrand/ortzrange).Closes #462, #1059
Open Tasks:
keyparameter for consistency withzoneinfo.ZoneInfoTZPATHtzdatablack(at least trying to be incremental here when we can...)Pull Request Checklist