[Python-checkins] CVS: python/dist/src/Lib calendar.py,1.23,1.24

Skip Montanaro montanaro@users.sourceforge.net
Fri, 15 Mar 2002 05:52:46 -0800


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

Modified Files:
	calendar.py 
Log Message:
Corrected _localized_name.__getitem__ based on code in patch 503202 (which I
thought was just a bug report, so didn't notice - doh!).  This handles
slicing, which v 1.23 didn't.  



Index: calendar.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** calendar.py	15 Mar 2002 04:08:38 -0000	1.23
--- calendar.py	15 Mar 2002 13:52:43 -0000	1.24
***************
*** 30,38 ****
          self.len = len
      def __getitem__(self, item):
!         if item > self.len-1 or item < -self.len:
!             raise IndexError
!         if item < 0:
!             item += self.len
!         return strftime(self.format, (item,)*9).capitalize()
      def __len__(self):
          return self.len
--- 30,40 ----
          self.len = len
      def __getitem__(self, item):
!         if isinstance(item, int):
!             if item < 0: item += self.len
!             if not 0 <= item < self.len:
!                 raise IndexError, "out of range"
!             return strftime(self.format, (item,)*9).capitalize()
!         elif isinstance(item, type(slice(0))):
!             return [self[e] for e in range(self.len)].__getslice__(item.start, item.stop)
      def __len__(self):
          return self.len
***************
*** 43,48 ****
  
  # Full and abbreviated names of months (1-based arrays!!!)
! month_name = _localized_name('%B', 12)
! month_abbr = _localized_name('%b', 12)
  
  # Constants for weekdays
--- 45,50 ----
  
  # Full and abbreviated names of months (1-based arrays!!!)
! month_name = _localized_name('%B', 13)
! month_abbr = _localized_name('%b', 13)
  
  # Constants for weekdays