summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gen_tzinfo.py3
-rw-r--r--src/pytz/__init__.py6
2 files changed, 8 insertions, 1 deletions
diff --git a/gen_tzinfo.py b/gen_tzinfo.py
index d06fa0e..5c0066c 100644
--- a/gen_tzinfo.py
+++ b/gen_tzinfo.py
@@ -129,7 +129,8 @@ def add_allzones(filename):
tz for tz in all_timezones if resource_exists(tz))
'''
print >> outf, 'all_timezones_set = LazySet(all_timezones)'
- print >> outf, '_all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones)'
+ # Per lp:1835784 we can't afford to do this at import time
+ # print >> outf, '_all_timezones_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones)'
print >> outf, 'common_timezones = \\'
pprint(cz, outf)
diff --git a/src/pytz/__init__.py b/src/pytz/__init__.py
index 5c05066..4d8f21d 100644
--- a/src/pytz/__init__.py
+++ b/src/pytz/__init__.py
@@ -188,8 +188,14 @@ def _unmunge_zone(zone):
return zone.replace('_plus_', '+').replace('_minus_', '-')
+_all_timezones_lower_to_standard = None
+
+
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
return _all_timezones_lower_to_standard.get(zone.lower()) or zone # noqa