From 3bd625a8ba3936c91f808235b33fc4ea351caffb Mon Sep 17 00:00:00 2001 From: Sean Doherty Date: Sun, 17 May 2026 04:48:48 -0500 Subject: [PATCH 1/4] Handle bare UTC and GMT in tzstr --- changelog.d/1492.bugfix.rst | 1 + src/dateutil/tz/tz.py | 6 +++++- tests/test_tz.py | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 changelog.d/1492.bugfix.rst diff --git a/changelog.d/1492.bugfix.rst b/changelog.d/1492.bugfix.rst new file mode 100644 index 000000000..10f8122d3 --- /dev/null +++ b/changelog.d/1492.bugfix.rst @@ -0,0 +1 @@ +Fixed ``tzstr()`` raising ``TypeError`` when parsing bare ``GMT`` or ``UTC`` names without an explicit offset. diff --git a/src/dateutil/tz/tz.py b/src/dateutil/tz/tz.py index 617591446..f0586ee46 100644 --- a/src/dateutil/tz/tz.py +++ b/src/dateutil/tz/tz.py @@ -1088,7 +1088,11 @@ def __init__(self, s, posix_offset=False): # Here we break the compatibility with the TZ variable handling. # GMT-3 actually *means* the timezone -3. - if res.stdabbr in ("GMT", "UTC") and not posix_offset: + if ( + res.stdabbr in ("GMT", "UTC") + and res.stdoffset is not None + and not posix_offset + ): res.stdoffset *= -1 # We must initialize it first, since _delta() needs diff --git a/tests/test_tz.py b/tests/test_tz.py index e5e4772d9..3698cd9e2 100644 --- a/tests/test_tz.py +++ b/tests/test_tz.py @@ -1471,6 +1471,14 @@ def testPosixOffset(self): self.assertEqual(datetime(2015, 1, 1, tzinfo=TZ2).utcoffset(), timedelta(hours=+3)) + def testBareUtcGmtOffset(self): + for tz_str in ("GMT", "UTC"): + TZ = tz.tzstr(tz_str) + dt = datetime(2015, 1, 1, tzinfo=TZ) + + self.assertEqual(dt.tzname(), tz_str) + self.assertEqual(dt.utcoffset(), timedelta(0)) + def testStrInequalityUnsupported(self): TZS = tz.tzstr('EST5EDT') From 709328c37d336d21e8206eb02154c4fd97906a35 Mon Sep 17 00:00:00 2001 From: Sean Doherty Date: Sun, 17 May 2026 05:25:07 -0500 Subject: [PATCH 2/4] Fix docs linkcheck timezone abbreviation link --- docs/exercises/index.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/exercises/index.rst b/docs/exercises/index.rst index bf4eed8a7..1243f83f9 100644 --- a/docs/exercises/index.rst +++ b/docs/exercises/index.rst @@ -125,7 +125,7 @@ To solve this exercise, copy-paste this script into a document, change anything Parsing a local tzname ---------------------- - Three-character time zone abbreviations are *not* unique in that they do not explicitly map to a time zone. A list of time zone abbreviations in use can be found `here `_. This means that parsing a datetime string such as ``'2018-01-01 12:30:30 CST'`` is ambiguous without context. Using :mod:`dateutil.parser` and :mod:`dateutil.tz`, it is possible to provide a context such that these local names are converted to proper time zones. + Three-character time zone abbreviations are *not* unique in that they do not explicitly map to a time zone. A list of time zone abbreviations in use can be found `here `_. This means that parsing a datetime string such as ``'2018-01-01 12:30:30 CST'`` is ambiguous without context. Using :mod:`dateutil.parser` and :mod:`dateutil.tz`, it is possible to provide a context such that these local names are converted to proper time zones. Problem 1 ********* @@ -239,4 +239,3 @@ To solve this exercise, copy-paste this script into a document, change anything .. raw:: html - From 3df1f0a8e2e121f5bf7129e592bc2d7668bd6281 Mon Sep 17 00:00:00 2001 From: Sean Doherty Date: Sun, 17 May 2026 05:31:28 -0500 Subject: [PATCH 3/4] Ignore flaky PDS linkcheck URL --- docs/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 2a249a0f6..e6181c4d6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -286,6 +286,8 @@ def pointer_mock(*args, **kwargs): r'https://pgp.mit.edu', # MetaCPAN frequently returns 402 for automated link checkers r"https://metacpan.org/.*", + # Planetary Rings Node frequently times out for automated link checkers + r"https://pds-rings.seti.org(:443)?/.*", ] # Reduce problems with ephemeral failures From d429f4ca0d00b6a3c8c937385eb752aaeaf60795 Mon Sep 17 00:00:00 2001 From: Sean Doherty Date: Sun, 17 May 2026 05:45:43 -0500 Subject: [PATCH 4/4] Update glibc TZ manual links --- src/dateutil/tz/tz.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dateutil/tz/tz.py b/src/dateutil/tz/tz.py index f0586ee46..84fdef5c5 100644 --- a/src/dateutil/tz/tz.py +++ b/src/dateutil/tz/tz.py @@ -1074,7 +1074,7 @@ class tzstr(tzrange): support is removed in a future version. .. _`GNU C Library: TZ Variable`: - https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html + https://sourceware.org/glibc/manual/latest/html_node/TZ-Variable.html """ def __init__(self, s, posix_offset=False): global parser @@ -1541,7 +1541,7 @@ class GettzFunc(object): .. _`TZ variable`: - https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html + https://sourceware.org/glibc/manual/latest/html_node/TZ-Variable.html .. _`"same zone" semantics`: https://blog.ganssle.io/articles/2018/02/aware-datetime-arithmetic.html