Mercurial > babel > mirror
changeset 254:fd9abff952f5 trunk
Fail more gracefully when formatting the timezone for an unknown/invalid territory.
author | cmlenz |
---|---|
date | Wed, 15 Aug 2007 12:41:40 +0000 |
parents | 2d9efe2d9c74 |
children | f9f6f740b595 |
files | babel/dates.py |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/babel/dates.py +++ b/babel/dates.py @@ -276,8 +276,10 @@ # 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