diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2002-11-27 08:30:25 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2002-11-27 08:30:25 (GMT) |
commit | e16e01fac6685e83a0121d1c6feca984fef8b946 (patch) | |
tree | 92f501581f05d3746e41352a21d2a0f98992027e /Lib/_strptime.py | |
parent | e4827eb2a2c9eed8911a6874866a224972ff40ab (diff) | |
download | cpython-e16e01fac6685e83a0121d1c6feca984fef8b946.zip cpython-e16e01fac6685e83a0121d1c6feca984fef8b946.tar.gz cpython-e16e01fac6685e83a0121d1c6feca984fef8b946.tar.bz2 |
Patch #639112: fixes for None locale and tz.
Diffstat (limited to 'Lib/_strptime.py')
-rw-r--r-- | Lib/_strptime.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Lib/_strptime.py b/Lib/_strptime.py index 5eeb370..896c050 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -26,7 +26,6 @@ from re import compile as re_compile from re import IGNORECASE from string import whitespace as whitespace_string -__version__ = (2,1,6) __author__ = "Brett Cannon" __email__ = "drifty@bigfoot.com" @@ -287,13 +286,19 @@ class LocaleTime(object): self.__timezone = self.__pad(time.tzname, 0) def __calc_lang(self): - # Set self.lang by using locale.getlocale() or - # locale.getdefaultlocale(). + # Set self.__lang by using locale.getlocale() or + # locale.getdefaultlocale(). If both turn up empty, set the attribute + # to ''. This is to stop calls to this method and to make sure + # strptime() can produce an re object correctly. current_lang = locale.getlocale(locale.LC_TIME)[0] if current_lang: self.__lang = current_lang else: - self.__lang = locale.getdefaultlocale()[0] + current_lang = locale.getdefaultlocale()[0] + if current_lang: + self.__lang = current_lang + else: + self.__lang = '' class TimeRE(dict): @@ -463,7 +468,10 @@ def strptime(data_string, format="%a %b %d %H:%M:%S %Y"): julian = int(found_dict['j']) elif group_key == 'Z': found_zone = found_dict['Z'].lower() - if locale_time.timezone[0].lower() == found_zone: + if locale_time.timezone[0] == locale_time.timezone[1]: + pass #Deals with bad locale setup where timezone info is + # the same; first found on FreeBSD 4.4 -current + elif locale_time.timezone[0].lower() == found_zone: tz = 0 elif locale_time.timezone[1].lower() == found_zone: tz = 1 |