Refs #32365 -- Allowed use of non-pytz timezone implementations.#13877
Refs #32365 -- Allowed use of non-pytz timezone implementations.#13877carltongibson merged 1 commit intodjango:masterfrom
Conversation
tests/timezones/tests.py
Outdated
There was a problem hiding this comment.
Note: This idiom gets repeated in a bunch of places, not sure if there's a "test support" module or something you want me to put it in. I frequently bury this sort of thing in a _compat module somewhere.
There was a problem hiding this comment.
I guess we could introduce django.utils.zoneinfo like we did with simplejson back in the time.
We could start deprecating the module when we drop support for Python 3.8.
There was a problem hiding this comment.
I wouldn't want anything user-facing here, since this is only ever used in the tests. If there's a common test utility module somewhere in the test suite where I can add functions like, "Get this IANA key in all supported time zone providers" and "skip this test if zoneinfo isn't available", it would make the PR a bit cleaner, but probably a lot of this stuff will get refactored for 4.0 anyway, so I don't think it's critical.
There was a problem hiding this comment.
right then I guess this import sequence is not too bad, it's already something we do in tests in a few other places when dealing with optional libraries.
|
Hey @pganssle — thanks for this! I've posted to the list about whether we can squeeze this in, if we can't get full review before Thursday. Are the TODOs in your first comment still up to date? |
|
@carltongibson I have updated the TODOs accordingly. I think that there are two remaining questions here:
That stuff is the only possible backwards-compatibility concern in this PR, since to the extent that it's possible to use In any case, I would say that even without any changes to the |
adamchainz
left a comment
There was a problem hiding this comment.
There are some pytz references in docs/i18n/timezones.txt that should likely be updated to be about "your timezone provider"
8707e3f to
600b67a
Compare
|
It seems ok to me. I added only a small comment. |
|
@adamchainz I've made some minor updates to the i18n documentation, but a lot of the references to I'd also say that this advice, while not so I think for now it's probably best to just acknowledge that non- |
aaugustin
left a comment
There was a problem hiding this comment.
Sorry I don't have time to perform a full review. At a high level this looks OK to me. Thanks Paul & everyone else involved!
6426279 to
cb6e4ca
Compare
de28198 to
b4a7cc7
Compare
b4a7cc7 to
5b8dbff
Compare
16c99aa to
3faef6f
Compare
1f58f2f to
3faef6f
Compare
3faef6f to
5fa92f9
Compare
|
🎉 |
|
Thanks so much for your help with this everyone. This was a great first experience contributing to Django ❤️ |
After django/django#13877, Django no longer checks for `hasattr(timezone, 'localize')` and instead does an inheritance check.
After django/django#13877, Django no longer checks for `hasattr(timezone, 'localize')` and instead does an inheritance check.

The current plan for switching Django over to use the
zoneinfomodule is a hard switch in Django 4.0, but in the meantime it would be prudent to make it at least possible to usezoneinfowith Django. I am not sure if this will be a perfectly smooth experience for the end user, but I've addedzoneinfo-based tests alongside (nearly) allpytz-based tests that I could find, then fixed any resulting errors.I know the deadline is very tight on this so I did not try to get too fancy with any formatting or the structures here so that we could get the review process started as soon as possible.
If this approach is acceptable, I think I still also need to add a few tests to:
tests/admin_widgets: unnecessary —pytzis not used for anything consequentialtests/admin_views: donetests/db_functions/test_extract_trunc(truncating with ambiguous and imaginary times — this may need a logic change as well).CC: @carltongibson @adamchainz