File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 8585 this now requires that setuptools be installed. (Patch by John
8686 Kristensen (jerrykan); additional doc changes (upgrade.txt,
8787 RELEASE.txt) John Rouillard)
88+ - issue2551128 - Impossible to validate a user with unknown timezone
89+ Raise KeyError when an unrecognized timezones is passed to
90+ pytz. (patch Cedric Krier, test John Rouillard)
8891
8992Features:
9093- issue2550522 - Add 'filter' command to command-line
Original file line number Diff line number Diff line change @@ -146,8 +146,12 @@ def get_timezone(tz):
146146 return SimpleTimezone (utcoffset )
147147 # tz is a timezone name
148148 if pytz :
149- return pytz .timezone (tz )
150- elif tz == "UTC" :
149+ try :
150+ return pytz .timezone (tz )
151+ except pytz .exceptions .UnknownTimeZoneError :
152+ pass
153+
154+ if tz == "UTC" :
151155 return UTC
152156 elif tz in _tzoffsets :
153157 return SimpleTimezone (_tzoffsets [tz ], tz )
Original file line number Diff line number Diff line change @@ -495,6 +495,16 @@ def testTZ(self):
495495 date = Date (date , tz )
496496 ae (str (date ), '2006-01-01.11:00:00' )
497497
498+ def testUnrecognizedTimezone (self ):
499+ '''Unrecognize timezone should raise key error'''
500+
501+ # unrecognized timezone
502+ tz = 'Zoot'
503+
504+ with self .assertRaises (KeyError ) as cm :
505+ date = Date ('2006-04-04.12:00:00' , tz )
506+
507+ self .assertEqual (cm .exception .args , ('Zoot' ,))
498508
499509class RangeTestCase (unittest .TestCase ):
500510
You can’t perform that action at this time.
0 commit comments