Skip to content

Commit 01592a9

Browse files
authored
Merge pull request #90 from eendebakpt/import_time_lazy_list
Draft: prevent evaluation of lazy list in pytz.timezone
2 parents 4ebc28d + 5e9f112 commit 01592a9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: gen_tzinfo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ def add_allzones(filename):
121121
cz.append(zone)
122122
cz.sort()
123123

124-
print('all_timezones = \\', file=outf)
124+
print('all_timezones_unchecked = \\', file=outf)
125125
pprint(sorted(allzones()), outf)
126126
print('''all_timezones = LazyList(
127-
tz for tz in all_timezones if resource_exists(tz))
127+
tz for tz in all_timezones_unchecked if resource_exists(tz))
128128
''', file=outf)
129129
print('all_timezones_set = LazySet(all_timezones)', file=outf)
130130
# Per lp:1835784 we can't afford to do this at import time

Diff for: src/pytz/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def _case_insensitive_zone_lookup(zone):
202202
"""case-insensitively matching timezone, else return zone unchanged"""
203203
global _all_timezones_lower_to_standard
204204
if _all_timezones_lower_to_standard is None:
205-
_all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones) # noqa
205+
_all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones_unchecked) # noqa
206206
return _all_timezones_lower_to_standard.get(zone.lower()) or zone # noqa
207207

208208

0 commit comments

Comments
 (0)