]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-114713: Handle case of an empty string passed to `zoneinfo.ZoneInfo` (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 15 Apr 2025 19:05:28 +0000 (21:05 +0200)
committerGitHub <noreply@github.com>
Tue, 15 Apr 2025 19:05:28 +0000 (19:05 +0000)
gh-114713: Handle case of an empty string passed to `zoneinfo.ZoneInfo` (GH-114731)
(cherry picked from commit 884df116d79b05d9342e05e50484d61c684ecb8b)

Co-authored-by: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Lib/test/test_zoneinfo/test_zoneinfo.py
Lib/zoneinfo/_tzpath.py
Misc/NEWS.d/next/Library/2025-03-09-01-09-12.gh-issue-114713.lkq9vZ.rst [new file with mode: 0644]

index 8bcd6d2e9951b964ca00bc20eb9bed3d9d887df7..e4eb4e1fe3778ef0efbc3ef25616c77de6a3b664 100644 (file)
@@ -235,6 +235,7 @@ class ZoneInfoTest(TzPathUserMixin, ZoneInfoTestBase):
             "../zoneinfo/America/Los_Angeles",  # Traverses above TZPATH
             "America/../America/Los_Angeles",  # Not normalized
             "America/./Los_Angeles",
+            "",
         ]
 
         for bad_key in bad_keys:
index 5db17bea045d8c8882601bbeb10fa2d6af850138..990a5c8b6a9372b1b599df0ba3a99af8dbd33884 100644 (file)
@@ -83,6 +83,11 @@ _TEST_PATH = os.path.normpath(os.path.join("_", "_"))[:-1]
 
 
 def _validate_tzfile_path(path, _base=_TEST_PATH):
+    if not path:
+        raise ValueError(
+            "ZoneInfo key must not be an empty string"
+        )
+
     if os.path.isabs(path):
         raise ValueError(
             f"ZoneInfo keys may not be absolute paths, got: {path}"
diff --git a/Misc/NEWS.d/next/Library/2025-03-09-01-09-12.gh-issue-114713.lkq9vZ.rst b/Misc/NEWS.d/next/Library/2025-03-09-01-09-12.gh-issue-114713.lkq9vZ.rst
new file mode 100644 (file)
index 0000000..d30975a
--- /dev/null
@@ -0,0 +1 @@
+Handle case of an empty string passed to :class:`zoneinfo.ZoneInfo`.