[Python-checkins] r43592 - python/trunk/Lib/calendar.py

walter.doerwald python-checkins at python.org
Mon Apr 3 17:24:49 CEST 2006


Author: walter.doerwald
Date: Mon Apr  3 17:24:49 2006
New Revision: 43592

Modified:
   python/trunk/Lib/calendar.py
Log:
For backwards compatibility reasons the global function
setfirstweekday() still needs to do a range check.


Modified: python/trunk/Lib/calendar.py
==============================================================================
--- python/trunk/Lib/calendar.py	(original)
+++ python/trunk/Lib/calendar.py	Mon Apr  3 17:24:49 2006
@@ -132,9 +132,10 @@
 
     def getfirstweekday(self):
         return self._firstweekday % 7
-    
+
     def setfirstweekday(self, firstweekday):
         self._firstweekday = firstweekday
+
     firstweekday = property(getfirstweekday, setfirstweekday)
 
     def iterweekdays(self):
@@ -159,7 +160,7 @@
         while True:
             yield date
             date += oneday
-            if date.month != month and date.weekday() == self.firstweekday%7:
+            if date.month != month and date.weekday() == self.firstweekday:
                 break
 
     def itermonthdays2(self, year, month):
@@ -567,7 +568,12 @@
 c = TextCalendar()
 
 firstweekday = c.getfirstweekday
-setfirstweekday = c.setfirstweekday
+
+def setfirstweekday(firstweekday):
+    if not MONDAY <= firstweekday <= SUNDAY:
+        raise IllegalWeekdayError(firstweekday)
+    c.firstweekday = firstweekday
+
 monthcalendar = c.monthdayscalendar
 prweek = c.prweek
 week = c.formatweek


More information about the Python-checkins mailing list