-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the deprecated pytz package #33980
Comments
We will be doing the Python 3.11 upgrade well before the Django 5.2 upgrade, so I think we can opt for second approach, do this after the Python 3.11 upgrade. |
As we are on Python 3.11, this is unblocked now. |
https://github.com/search?q=repo%3Aopenedx%2Fedx-platform+country_timezones+language%3APython&type=code |
Description
pytz
got deprecated in Django 4.0 && has been completely removed in Django 5.0.USE_DEPRECATED_PYTZ
flag forpytz
support which has now been completely removed in Django 5.0 as well.Django
now useszoneinfo
by default anddatetime
module use this under the hood now instead ofpytz
Difference between datetime.timezone and zoneinfo
datetime.timezone
and thezoneinfo
package are both related to handling time zones in Python, but they serve slightly different purposes and have different use cases.datetime.timezone
zoneinfo
zoneinfo
package is introduced inPython 3.9
as part ofPEP 615
.IANA Time Zone
Database, which is regularly updated to reflect changes in time zones around the world.pytz usages to replace
import pytz
→ 268 files inopenedx/edx-platform
.pytz.UTC
→ 97 files inopenedx/edx-platform
.Potential Solution
python<3.9
,Django
providesbackports.zoneinfo
for backward support.datetime
objects created withpytz.UTC
are equivalent to the ones created withZoneInfo("UTC")
- see https://gist.github.com/jwhitlock/08ca74b037c2196f946262ef1a4b775dApproach 01
pytz.UTC
withbackports.zoneinfo.UTC
Python>3.9
backports.zoneinfo
withzoneinfo
Approach 02
Python 3.8
toPython 3.9
pytz.UTC
withzoneinfo.UTC
The text was updated successfully, but these errors were encountered: