bind-adblock icon indicating copy to clipboard operation
bind-adblock copied to clipboard

update-zonefile.py:70: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version

Open CRCinAU opened this issue 1 year ago • 2 comments

The following warning is printed when running update-zonefile.py on Fedora 40.

update-zonefile.py:70: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
  last_modified = datetime.utcfromtimestamp(cache.stat().st_mtime)

Python environment installed:

rpm -qa | grep python | sort
python3-3.12.7-1.fc40.x86_64
python3-charset-normalizer-3.3.2-3.fc40.noarch
python3-dateutil-2.8.2-13.fc40.noarch
python3-dbus-1.3.2-6.fc40.x86_64
python3-decorator-5.1.1-9.fc40.noarch
python3-distro-1.9.0-3.fc40.noarch
python3-dnf-4.21.1-1.fc40.noarch
python3-dnf-plugins-core-4.9.0-1.fc40.noarch
python3-dns-2.6.1-1.fc40.noarch
python3-hawkey-0.73.3-1.fc40.x86_64
python3-idna-3.7-1.fc40.noarch
python3-libcomps-0.1.20-5.fc40.x86_64
python3-libdnf-0.73.3-1.fc40.x86_64
python3-libs-3.12.7-1.fc40.x86_64
python3-pysocks-1.7.1-22.fc40.noarch
python3-pyyaml-6.0.1-14.fc40.x86_64
python3-requests-2.31.0-3.fc40.noarch
python3-rpm-4.19.1.1-1.fc40.x86_64
python3-six-1.16.0-14.fc40.noarch
python3-systemd-235-9.fc40.x86_64
python3-unbound-1.21.1-3.fc40.x86_64
python3-urllib3-1.26.20-1.fc40.noarch
python3-urllib3+socks-1.26.20-1.fc40.noarch
python3-validators-0.20.0-6.fc40.noarch
python-pip-wheel-23.3.2-2.fc40.noarch
python-unversioned-command-3.12.7-1.fc40.noarch

CRCinAU avatar Oct 23 '24 05:10 CRCinAU

to fix this change line 26 from datetime import datetime to from datetime import datetime, timezone

and line 70 last_modified = datetime.utcfromtimestamp(cache.stat().st_mtime) to last_modified = datetime.fromtimestamp(cache.stat().st_mtime, tz=timezone.utc)

zinc69 avatar Dec 03 '25 05:12 zinc69

Can confirm, that removes the errors.

CRCinAU avatar Dec 03 '25 13:12 CRCinAU