Skip to content

Commit 8df2471

Browse files
authored
Use !r
1 parent bc9a0fb commit 8df2471

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Lib/zoneinfo/_common.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@ def load_tzdata(key):
1414
if path.is_dir():
1515
raise IsADirectoryError
1616
return path.open("rb")
17-
except UnicodeEncodeError:
18-
# This error occurs because of unsupported filesystem encoding which
19-
# depends on the locale, such as keys containing a surrogate character.
20-
ZoneInfoNotFoundError(f"key {key} contains non-UTF8 character(s)")
2117
except (ImportError, FileNotFoundError, UnicodeEncodeError, IsADirectoryError):
22-
# There are three other types of exception that can be raised that
23-
# all amount to "we cannot find this key":
18+
# There are four types of exception that can be raised that all amount
19+
# to "we cannot find this key":
2420
#
2521
# ImportError: If package_name doesn't exist (e.g. if tzdata is not
2622
# installed, or if there's an error in the folder name like
2723
# Amrica/New_York)
2824
# FileNotFoundError: If resource_name doesn't exist in the package
2925
# (e.g. Europe/Krasnoy)
26+
# UnicodeEncodeError: If package_name or resource_name are not UTF-8,
27+
# such as keys containing a surrogate character.
3028
# IsADirectoryError: If package_name without a resource_name specified.
31-
raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
29+
raise ZoneInfoNotFoundError(f"No time zone found with key {key!r}")
3230

3331

3432
def load_data(fobj):

0 commit comments

Comments
 (0)