From 208f8b156517cf74240b02a11593f5ea4a9054a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 16 Mar 2021 17:51:52 +0100 Subject: [PATCH] Always close the zone.tab file Otherwise we get this in setuptools build with pytest 6.2+: > warnings.warn(pytest.PytestUnraisableExceptionWarning(msg)) E pytest.PytestUnraisableExceptionWarning: Exception ignored in: <_io.FileIO [closed]> E E Traceback (most recent call last): E File "/usr/lib/python3.9/site-packages/pytz/__init__.py", line 522, in E common_timezones = [l.split()[2] E ResourceWarning: unclosed file <_io.TextIOWrapper name='/usr/share/zoneinfo/zone.tab' mode='r' encoding='UTF-8'> /usr/lib/python3.9/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning --- pytz-zoneinfo.patch | 13 ++++++------- pytz.spec | 5 ++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pytz-zoneinfo.patch b/pytz-zoneinfo.patch index 3cc3d8d..caffa15 100644 --- a/pytz-zoneinfo.patch +++ b/pytz-zoneinfo.patch @@ -1,5 +1,5 @@ diff --git a/pytz/__init__.py b/pytz/__init__.py -index d217c96..2b1ac03 100644 +index e2f49fa..65c1d11 100644 --- a/pytz/__init__.py +++ b/pytz/__init__.py @@ -74,6 +74,9 @@ else: # Python 2.x @@ -38,9 +38,7 @@ index d217c96..2b1ac03 100644 return open(filename, 'rb') ---- a/pytz/__init__.py~ 2020-12-24 16:02:19.111185746 -0600 -+++ b/pytz/__init__.py 2020-12-28 13:16:13.399004167 -0600 -@@ -502,1044 +502,37 @@ +@@ -514,1044 +502,38 @@ def _test(): if __name__ == '__main__': _test() @@ -1095,9 +1093,10 @@ index d217c96..2b1ac03 100644 - 'US/Pacific', - 'UTC'] + -+common_timezones = [l.split()[2] -+ for l in open(os.path.join(_tzinfo_dir, 'zone.tab')) -+ if l != '' and l[0] != '#'] ++with open(os.path.join(_tzinfo_dir, 'zone.tab')) as zonetab: ++ common_timezones = [l.split()[2] ++ for l in zonetab ++ if l != '' and l[0] != '#'] +common_timezones.extend( + ['GMT', + 'US/Alaska', diff --git a/pytz.spec b/pytz.spec index 69954d1..9d3b5d9 100644 --- a/pytz.spec +++ b/pytz.spec @@ -12,7 +12,7 @@ Name: pytz Version: 2021.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: World Timezone Definitions for Python License: MIT @@ -107,6 +107,9 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} -m pytest -v %changelog +* Tue Mar 16 2021 Miro HronĨok - 2021.1-2 +- Always close the zone.tab file + * Mon Feb 01 2021 Gwyn Ciesla - 2021.1-1 - 2021.1