Skip to content

Commit 5d1890c

Browse files
committed
Don't use "raise from" in load_tzdata
Most of the time the context of the exception is not useful, because this only catches exceptions in the fallback data source. It adds a bunch of stuff about failing to load the zone from `tzdata` even if tzdata is not installed and would be misleading to end users.
1 parent edeab39 commit 5d1890c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/zoneinfo/_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def load_tzdata(key):
1010

1111
try:
1212
return importlib.resources.open_binary(package_name, resource_name)
13-
except (ImportError, FileNotFoundError, UnicodeEncodeError) as e:
13+
except (ImportError, FileNotFoundError, UnicodeEncodeError):
1414
# There are three types of exception that can be raised that all amount
1515
# to "we cannot find this key":
1616
#
@@ -21,7 +21,7 @@ def load_tzdata(key):
2121
# (e.g. Europe/Krasnoy)
2222
# UnicodeEncodeError: If package_name or resource_name are not UTF-8,
2323
# such as keys containing a surrogate character.
24-
raise ZoneInfoNotFoundError(f"No time zone found with key {key}") from e
24+
raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
2525

2626

2727
def load_data(fobj):

0 commit comments

Comments
 (0)