[Python-checkins] python/dist/src/Lib _strptime.py,1.8,1.9

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Wed, 15 Jan 2003 14:59:41 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv29981

Modified Files:
	_strptime.py 
Log Message:
Checking in Brett Cannon's patch #662053, which fixes bug #661354.
_strptime can now handle getting two empty strings as the timezone information.


Index: _strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/_strptime.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** _strptime.py	30 Dec 2002 22:23:12 -0000	1.8
--- _strptime.py	15 Jan 2003 22:59:39 -0000	1.9
***************
*** 259,269 ****
                      # '3' needed for when no leading zero.
                      ('2', '%w'), ('10', '%I')):
!                 try:
!                     # Done this way to deal with possible lack of locale info
!                     # manifesting itself as the empty string (i.e., Swedish's
!                     # lack of AM/PM info).
                      current_format = current_format.replace(old, new)
-                 except ValueError:
-                     pass
              time_tuple = time.struct_time((1999,1,3,1,1,1,6,3,0))
              if time.strftime(directive, time_tuple).find('00'):
--- 259,268 ----
                      # '3' needed for when no leading zero.
                      ('2', '%w'), ('10', '%I')):
!                 # Must deal with possible lack of locale info
!                 # manifesting itself as the empty string (e.g., Swedish's
!                 # lack of AM/PM info) or a platform returning a tuple of empty
!                 # strings (e.g., MacOS 9 having timezone as ('','')).
!                 if old:
                      current_format = current_format.replace(old, new)
              time_tuple = time.struct_time((1999,1,3,1,1,1,6,3,0))
              if time.strftime(directive, time_tuple).find('00'):
***************
*** 352,356 ****
  
      def __seqToRE(self, to_convert, directive):
!         """Convert a list to a regex string for matching directive."""
          def sorter(a, b):
              """Sort based on length.
--- 351,355 ----
  
      def __seqToRE(self, to_convert, directive):
!         """Convert a list to a regex string for matching a directive."""
          def sorter(a, b):
              """Sort based on length.
***************
*** 371,374 ****
--- 370,378 ----
  
          to_convert = to_convert[:]  # Don't want to change value in-place.
+         for value in to_convert:
+             if value != '':
+                 break
+         else:
+             return ''
          to_convert.sort(sorter)
          regex = '|'.join(to_convert)
***************
*** 474,478 ****
                  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
--- 478,482 ----
                  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.
                  elif locale_time.timezone[0].lower() == found_zone:
                      tz = 0