[Python-checkins] python/dist/src/Lib _strptime.py,1.25,1.26
bcannon at users.sourceforge.net
bcannon at users.sourceforge.net
Mon Aug 11 01:24:07 EDT 2003
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv1618/Lib
Modified Files:
_strptime.py
Log Message:
Fix handling of bad locale setup where time.tzname[0] == time.tzname[1] and
time.daylight is true. Add an explicit test for this situation.
Fixed some wording in docstrings.
Index: _strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/_strptime.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** _strptime.py 8 Aug 2003 01:53:05 -0000 1.25
--- _strptime.py 11 Aug 2003 07:24:05 -0000 1.26
***************
*** 65,68 ****
--- 65,72 ----
running. The check here is done in case someone does not think about
doing this.
+
+ Only other possible issue is if someone changed the timezone and did
+ not call tz.tzset . That is an issue for the programmer, though,
+ since changing the timezone is worthless without that call.
"""
***************
*** 156,159 ****
--- 160,165 ----
def __calc_timezone(self):
# Set self.timezone by using time.tzname.
+ # Do not worry about possibility of time.tzname[0] == timetzname[1]
+ # and time.daylight; handle that in strptime .
try:
time.tzset()
***************
*** 238,242 ****
Need to make sure that any characters that might be interpreted as
! regex syntax is escaped.
"""
--- 244,248 ----
Need to make sure that any characters that might be interpreted as
! regex syntax are escaped.
"""
***************
*** 264,272 ****
# first!
_TimeRE_cache = TimeRE()
! _CACHE_MAX_SIZE = 5
_regex_cache = {}
def strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
! """Return a time struct based on the input data and the format string."""
global _TimeRE_cache
_cache_lock.acquire()
--- 270,278 ----
# first!
_TimeRE_cache = TimeRE()
! _CACHE_MAX_SIZE = 5 # Max number of regexes stored in _regex_cache
_regex_cache = {}
def strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
! """Return a time struct based on the input string and the format string."""
global _TimeRE_cache
_cache_lock.acquire()
***************
*** 356,367 ****
# it can be something other than -1.
found_zone = found_dict['Z'].lower()
! if locale_time.timezone[0] == locale_time.timezone[1] and \
! time.daylight:
! pass #Deals with bad locale setup where timezone info is
! # the same; first found on FreeBSD 4.4.
! else:
! for value, tz_values in enumerate(locale_time.timezone):
! if found_zone in tz_values:
tz = value
# Cannot pre-calculate datetime_date() since can change in Julian
#calculation and thus could have different value for the day of the week
--- 362,376 ----
# it can be something other than -1.
found_zone = found_dict['Z'].lower()
! for value, tz_values in enumerate(locale_time.timezone):
! if found_zone in tz_values:
! # Deal with bad locale setup where timezone names are the
! # same and yet time.daylight is true; too ambiguous to
! # be able to tell what timezone has daylight savings
! if time.tzname[0] == time.tzname[1] and \
! time.daylight:
! break
! else:
tz = value
+ break
# Cannot pre-calculate datetime_date() since can change in Julian
#calculation and thus could have different value for the day of the week
More information about the Python-checkins
mailing list