diff -r 5fb1057bd490 Lib/calendar.py --- a/Lib/calendar.py Sat Jul 21 21:23:00 2012 -0700 +++ b/Lib/calendar.py Sun Jul 22 16:23:11 2012 +0200 @@ -161,7 +161,10 @@ oneday = datetime.timedelta(days=1) while True: yield date - date += oneday + try: + date += oneday + except OverflowError: + break if date.month != month and date.weekday() == self.firstweekday: break diff -r 5fb1057bd490 Lib/test/test_calendar.py --- a/Lib/test/test_calendar.py Sat Jul 21 21:23:00 2012 -0700 +++ b/Lib/test/test_calendar.py Sun Jul 22 16:23:11 2012 +0200 @@ -262,6 +262,10 @@ new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) self.assertEquals(old_october, new_october) + def test_itermonthdates(self): + # ensure itermonthdates works for all months + list(calendar.Calendar().itermonthdates(9999, 12)) + class MonthCalendarTestCase(unittest.TestCase): def setUp(self):