On 05/03/2023 23:07, Felix Geyer wrote:
On Sun, 05 Mar 2023 18:50:06 +0100 Arnout Vandecappelle
<arnout.vandecappe...@essensium.com> wrote:
This still fails to address the original issue: an irrelevant warning is
printed when performing a fairly mundane thing (requesting a nonexistent
timezone).
That part could be easily fixed. We can just remove the fallback from
dateutil.tz.gettz() to get_zonefile_instance() since we know that the system
database is available.
OK, attached patch does exactly that.
I repeat: I don't think anyone really wants to use the bundled database.
That's probably true but there are direct users of the dateutil.zoneinfo API
which intrinsically uses the bundled database.
For example within Debian packages:
https://sources.debian.org/src/python-hypothesis/6.67.1-1/hypothesis-python/src/hypothesis/extra/dateutil.py/?hl=56#L56
https://sources.debian.org/src/python-sqlalchemy-utils/0.38.2-2/sqlalchemy_utils/types/timezone.py/?hl=44#L44
These are currently broken. Just silencing the warning will leave them broken.
Good point. However, this has been the case already since 2014-ish, so I think
that would be a separate bug, and probably not "grave".
Regards,
Arnout
We could patch the implementation to use the system database but that means
deviating from the upstream behavior and carrying that patch forever.
The API even includes the metadata dictionary that would have to be faked as
well:
https://sources.debian.org/src/python-dateutil/2.8.2-1/dateutil/zoneinfo/__init__.py/#L46
Therefore shipping the bundled zoneinfo tarball seems like the better solution
to me.
The timezone database is clearly DFSG-free. We would have to repackage the
upstream tarball to include the timezone database source though.
Thankfully upstream ships the script to (re-)generate the zoneinfo tarball.
Felix
diff -Nru python-dateutil-2.8.2/debian/changelog python-dateutil-2.8.2/debian/changelog
--- python-dateutil-2.8.2/debian/changelog 2022-10-14 13:10:49.000000000 +0200
+++ python-dateutil-2.8.2/debian/changelog 2023-03-03 18:58:30.000000000 +0100
@@ -1,3 +1,10 @@
+python-dateutil (2.8.2-1.1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Don't fall back on bundled zoneinfo database (Closes: #1003044)
+
+ -- Arnout Vandecappelle <arn...@mind.be> Fri, 03 Mar 2023 18:58:30 +0100
+
python-dateutil (2.8.2-1) unstable; urgency=medium
* Team upload
diff -Nru python-dateutil-2.8.2/debian/patches/Remove_Zoneinfo_Tarball.patch python-dateutil-2.8.2/debian/patches/Remove_Zoneinfo_Tarball.patch
--- python-dateutil-2.8.2/debian/patches/Remove_Zoneinfo_Tarball.patch 2022-10-14 13:10:49.000000000 +0200
+++ python-dateutil-2.8.2/debian/patches/Remove_Zoneinfo_Tarball.patch 2023-03-03 18:58:30.000000000 +0100
@@ -1,13 +1,15 @@
-From: =?utf-8?q?Guido_G=C3=BCnther?= <a...@sigxcpu.org>
+From 49f1a86aa7989e497114437dfef8ad51d5b413fe Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Guido=20G=C3=BCnther?= <a...@sigxcpu.org>
Date: Sat, 27 Sep 2014 20:52:15 +0200
-Subject: Remove Zoneinfo Tarball
+Subject: [PATCH] Remove Zoneinfo Tarball
---
MANIFEST.in | 1 +
dateutil/test/test_tz.py | 2 ++
+ dateutil/tz/tz.py | 4 ----
python_dateutil.egg-info/SOURCES.txt | 3 +--
setup.cfg | 3 ---
- 4 files changed, 4 insertions(+), 5 deletions(-)
+ 5 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/MANIFEST.in b/MANIFEST.in
index d4d9f32..3e8b3fb 100644
@@ -19,7 +21,7 @@
global-exclude *.py[co]
+exclude dateutil/zoneinfo/dateutil-zoneinfo.tar.gz
diff --git a/dateutil/test/test_tz.py b/dateutil/test/test_tz.py
-index 6cd8ea0..042f28e 100644
+index e5e4772..fa84872 100644
--- a/dateutil/test/test_tz.py
+++ b/dateutil/test/test_tz.py
@@ -1193,6 +1193,7 @@ def test_gettz_weakref():
@@ -38,8 +40,23 @@
def testPickleZoneFileGettz(self):
zoneinfo_file = zoneinfo.get_zonefile_instance()
tzi = zoneinfo_file.get('America/New_York')
+diff --git a/dateutil/tz/tz.py b/dateutil/tz/tz.py
+index c67f56d..e350cdb 100644
+--- a/dateutil/tz/tz.py
++++ b/dateutil/tz/tz.py
+@@ -1650,10 +1650,6 @@ def __get_gettz():
+ # UnicodeEncodeError is for Python 2.7 compat
+ tz = None
+
+- if not tz:
+- from dateutil.zoneinfo import get_zonefile_instance
+- tz = get_zonefile_instance().get(name)
+-
+ if not tz:
+ for c in name:
+ # name is not a tzstr unless it has at least
diff --git a/python_dateutil.egg-info/SOURCES.txt b/python_dateutil.egg-info/SOURCES.txt
-index c0d2a0f..ae4d43f 100644
+index c8e5497..a0ccdca 100644
--- a/python_dateutil.egg-info/SOURCES.txt
+++ b/python_dateutil.egg-info/SOURCES.txt
@@ -60,7 +60,6 @@ dateutil/tz/_factories.py
@@ -58,7 +75,7 @@
\ No newline at end of file
+requirements/3.3/requirements-dev.txt
diff --git a/setup.cfg b/setup.cfg
-index a5fe172..330b7cb 100644
+index 33283f9..f815c88 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -45,9 +45,6 @@ test_suite = dateutil.test
@@ -71,3 +88,6 @@
[sdist]
formats = gztar
+--
+2.39.2
+