Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: prevent evaluation of lazy list in pytz.timezone #90

Merged
merged 1 commit into from Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions gen_tzinfo.py
Expand Up @@ -121,10 +121,10 @@ def add_allzones(filename):
cz.append(zone)
cz.sort()

print('all_timezones = \\', file=outf)
print('all_timezones_unchecked = \\', file=outf)
pprint(sorted(allzones()), outf)
print('''all_timezones = LazyList(
tz for tz in all_timezones if resource_exists(tz))
tz for tz in all_timezones_unchecked if resource_exists(tz))
''', file=outf)
print('all_timezones_set = LazySet(all_timezones)', file=outf)
# Per lp:1835784 we can't afford to do this at import time
Expand Down
2 changes: 1 addition & 1 deletion src/pytz/__init__.py
Expand Up @@ -202,7 +202,7 @@ def _case_insensitive_zone_lookup(zone):
"""case-insensitively matching timezone, else return zone unchanged"""
global _all_timezones_lower_to_standard
if _all_timezones_lower_to_standard is None:
_all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones) # noqa
_all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones_unchecked) # noqa
return _all_timezones_lower_to_standard.get(zone.lower()) or zone # noqa


Expand Down