[I picked up this bug as part of a Debian bugsquashing sprint together with my 
colleagues.]

 Since there's been some back-and-forth in this thread, let me first summarize 
the status.

- The following will print an ugly warning:

In [1]: from dateutil import zoneinfo

In [2]: zoneinfo.get_zonefile_instance()
/usr/lib/python3/dist-packages/dateutil/zoneinfo/__init__.py:26:
UserWarning: I/O error(2): No such file or directory
 warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror))
Out[2]: <dateutil.zoneinfo.ZoneInfoFile at 0x7f5810824bd0>


- It's just a warning, but it may confuse tools that consume stderr, or build
  scripts may fail if anything is emitted on stderr.

- The warning can also be triggered by requesting a timezone that doesn't exist:

In [1]: from dateutil import tz In [2]: tz.gettz('foo') /usr/lib/python3/dist-packages/dateutil/zoneinfo/__init__.py:26: UserWarning: I/O error(2): No such file or directory  warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) - In this case, the warning is in fact useless: if a timezone doesn't exist in the system database, it doesn't exist. - Thus, the only case where the warning is relevant is when the bundled database is used explicitly (by calling zoneinfo.get_zonefile_instance()).
  However, this is not really a valid use case.


 I conclude from this that all that really has to be done is to remove the
warning. Since the debian package doesn't have the bundled zoneinfo database,
it is not useful to issue a warning when there is no bundled zoneinfo database.
This bug is about the warning, not about the fact that the bundled zoninfo
database is missing.

 Therefore, the attached patch removes the warning. This is done as part of
Remove_Zoneinfo_Tarball.patch because removing the database should really go hand in hand with removing the warning. [Note that this is my first time contribution to Debian packaging. I'm actually using Fedora myself :-). The patch was tested by building it with pbuilder and running it in a bookworm container. Please let me know if there is anything else I should do, or if there is anything I should have done differently.] Regards, Arnout
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.
+  * Remove warning about missing 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
@@ -5,9 +5,10 @@
 ---
  MANIFEST.in                          | 1 +
  dateutil/test/test_tz.py             | 2 ++
+ dateutil/zoneinfo/__init__.py        | 1 -
  python_dateutil.egg-info/SOURCES.txt | 3 +--
  setup.cfg                            | 3 ---
- 4 files changed, 4 insertions(+), 5 deletions(-)
+ 5 files changed, 4 insertions(+), 6 deletions(-)
 
 diff --git a/MANIFEST.in b/MANIFEST.in
 index d4d9f32..3e8b3fb 100644
@@ -38,6 +39,18 @@
      def testPickleZoneFileGettz(self):
          zoneinfo_file = zoneinfo.get_zonefile_instance()
          tzi = zoneinfo_file.get('America/New_York')
+diff --git a/dateutil/zoneinfo/__init__.py b/dateutil/zoneinfo/__init__.py
+index 34f11ad..18021dc 100644
+--- a/dateutil/zoneinfo/__init__.py
++++ b/dateutil/zoneinfo/__init__.py
+@@ -23,7 +23,6 @@ def getzoneinfofile_stream():
+     try:
+         return BytesIO(get_data(__name__, ZONEFILENAME))
+     except IOError as e:  # TODO  switch to FileNotFoundError?
+-        warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror))
+         return None
+ 
+ 
 diff --git a/python_dateutil.egg-info/SOURCES.txt b/python_dateutil.egg-info/SOURCES.txt
 index c0d2a0f..ae4d43f 100644
 --- a/python_dateutil.egg-info/SOURCES.txt

Reply via email to