]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fail more gracefully when formatting the timezone for an unknown/invalid territory.
authorChristopher Lenz <cmlenz@gmail.com>
Wed, 15 Aug 2007 12:41:40 +0000 (12:41 +0000)
committerChristopher Lenz <cmlenz@gmail.com>
Wed, 15 Aug 2007 12:41:40 +0000 (12:41 +0000)
babel/dates.py

index df722635c8be899d1b6b99cbdafb5209de2a306c..daea499988d8b636d863d89d45a3340364f57f7d 100644 (file)
@@ -276,8 +276,10 @@ def get_timezone_location(dt_or_tzinfo=None, locale=LC_TIME):
     # localized country name
     region_format = locale.zone_formats['region']
     territory = get_global('zone_territories').get(zone)
+    if territory not in locale.territories:
+        territory = 'ZZ' # invalid/unknown
     territory_name = locale.territories[territory]
-    if territory and len(get_global('territory_zones')[territory]) == 1:
+    if territory and len(get_global('territory_zones').get(territory, [])) == 1:
         return region_format % (territory_name)
 
     # Otherwise, include the city in the output