close
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions babel/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,17 @@ def get_timezone(zone: str | datetime.tzinfo | None = None) -> datetime.tzinfo:
if not isinstance(zone, str):
return zone

exc = None
if pytz:
try:
return pytz.timezone(zone)
except pytz.UnknownTimeZoneError as exc: # noqa: F841
pass
except pytz.UnknownTimeZoneError as e:
exc = e
Comment on lines +249 to +250
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the variable is not used, can't it be removed?

Suggested change
except pytz.UnknownTimeZoneError as e:
exc = e
except pytz.UnknownTimeZoneError:
pass

else:
assert zoneinfo
try:
return zoneinfo.ZoneInfo(zone)
except zoneinfo.ZoneInfoNotFoundError as exc: # noqa: F841
pass
except zoneinfo.ZoneInfoNotFoundError as e:
exc = e

raise LookupError(f"Unknown timezone {zone}") from exc

Expand Down