#15421: fix an OverflowError in Calendar.itermonthdates() after datetime.MAXYEAR. Patch by Cédric Krier.

This commit is contained in:
Ezio Melotti 2012-09-21 17:26:35 +03:00
parent 003014bf1e
commit cadff70ba5
3 changed files with 14 additions and 1 deletions

View file

@ -161,7 +161,11 @@ class Calendar(object):
oneday = datetime.timedelta(days=1)
while True:
yield date
date += oneday
try:
date += oneday
except OverflowError:
# Adding one day could fail after datetime.MAXYEAR
break
if date.month != month and date.weekday() == self.firstweekday:
break