diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-09-21 14:26:35 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-09-21 14:26:35 (GMT) |
commit | 85710a40e7e9eab86060bedc3762ccf9ca8d26ca (patch) | |
tree | 34df432ef5160f2bff895cca080e63760357d376 /Lib/calendar.py | |
parent | e418d760897cc6f6f4dedb364f80f3f52525ffa6 (diff) | |
download | cpython-85710a40e7e9eab86060bedc3762ccf9ca8d26ca.zip cpython-85710a40e7e9eab86060bedc3762ccf9ca8d26ca.tar.gz cpython-85710a40e7e9eab86060bedc3762ccf9ca8d26ca.tar.bz2 |
#15421: fix an OverflowError in Calendar.itermonthdates() after datetime.MAXYEAR. Patch by Cédric Krier.
Diffstat (limited to 'Lib/calendar.py')
-rw-r--r-- | Lib/calendar.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/calendar.py b/Lib/calendar.py index 0301d6b..3bbf399 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -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 |