@@ -258,13 +258,12 @@ def __calc_date_time(self):
258258 ('17' , '%d' ), ('03' , '%m' ), ('3' , '%m' ),
259259 # '3' needed for when no leading zero.
260260 ('2' , '%w' ), ('10' , '%I' )):
261- try :
262- # Done this way to deal with possible lack of locale info
263- # manifesting itself as the empty string (i.e., Swedish's
264- # lack of AM/PM info).
261+ # Must deal with possible lack of locale info
262+ # manifesting itself as the empty string (e.g., Swedish's
263+ # lack of AM/PM info) or a platform returning a tuple of empty
264+ # strings (e.g., MacOS 9 having timezone as ('','')).
265+ if old :
265266 current_format = current_format .replace (old , new )
266- except ValueError :
267- pass
268267 time_tuple = time .struct_time ((1999 ,1 ,3 ,1 ,1 ,1 ,6 ,3 ,0 ))
269268 if time .strftime (directive , time_tuple ).find ('00' ):
270269 U_W = '%U'
@@ -351,7 +350,7 @@ def __getitem__(self, fetch):
351350 raise
352351
353352 def __seqToRE (self , to_convert , directive ):
354- """Convert a list to a regex string for matching directive."""
353+ """Convert a list to a regex string for matching a directive."""
355354 def sorter (a , b ):
356355 """Sort based on length.
357356
@@ -370,6 +369,11 @@ def sorter(a, b):
370369 return cmp (b_length , a_length )
371370
372371 to_convert = to_convert [:] # Don't want to change value in-place.
372+ for value in to_convert :
373+ if value != '' :
374+ break
375+ else :
376+ return ''
373377 to_convert .sort (sorter )
374378 regex = '|' .join (to_convert )
375379 regex = '(?P<%s>%s' % (directive , regex )
@@ -473,7 +477,7 @@ def strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
473477 found_zone = found_dict ['Z' ].lower ()
474478 if locale_time .timezone [0 ] == locale_time .timezone [1 ]:
475479 pass #Deals with bad locale setup where timezone info is
476- # the same; first found on FreeBSD 4.4 -current
480+ # the same; first found on FreeBSD 4.4.
477481 elif locale_time .timezone [0 ].lower () == found_zone :
478482 tz = 0
479483 elif locale_time .timezone [1 ].lower () == found_zone :
0 commit comments