mirror of https://github.com/python/cpython
#15421: merge with 3.2.
This commit is contained in:
commit
f82b9371f5
|
@ -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
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from test.script_helper import assert_python_ok
|
|||
import time
|
||||
import locale
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
result_2004_01_text = """
|
||||
January 2004
|
||||
|
@ -464,6 +465,11 @@ class CalendarTestCase(unittest.TestCase):
|
|||
new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
|
||||
self.assertEqual(old_october, new_october)
|
||||
|
||||
def test_itermonthdates(self):
|
||||
# ensure itermonthdates doesn't overflow after datetime.MAXYEAR
|
||||
# see #15421
|
||||
list(calendar.Calendar().itermonthdates(datetime.MAXYEAR, 12))
|
||||
|
||||
|
||||
class MonthCalendarTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue