This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients, rhettinger, serhiy.storchaka, xiang.zhang
Date 2016-09-23.08:51:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This is not just not elegant, but it doesn't work if firstweekday is not 0.

The lowest level in the calendar module is itermonthdates(). But the problem is that dates outside supported range can't be represented.

While the output for December of the year 9999 looks badly formatted, calendar doesn't work at all with January of the year 1 if firstweekday is not 0:

>>> import calendar
>>> calendar.setfirstweekday(6)
>>> calendar.prmonth(1, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython-3.6/Lib/", line 318, in prmonth
    print(self.formatmonth(theyear, themonth, w, l), end=' ')
  File "/home/serhiy/py/cpython-3.6/Lib/", line 331, in formatmonth
    for week in self.monthdays2calendar(theyear, themonth):
  File "/home/serhiy/py/cpython-3.6/Lib/", line 211, in monthdays2calendar
    days = list(self.itermonthdays2(year, month))
  File "/home/serhiy/py/cpython-3.6/Lib/", line 179, in itermonthdays2
    for date in self.itermonthdates(year, month):
  File "/home/serhiy/py/cpython-3.6/Lib/", line 162, in itermonthdates
    date -= datetime.timedelta(days=days)
OverflowError: date value out of range
Date User Action Args
2016-09-23 08:51:31serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, xiang.zhang,
2016-09-23 08:51:31serhiy.storchakasetmessageid: <>
2016-09-23 08:51:31serhiy.storchakalinkissue28253 messages
2016-09-23 08:51:30serhiy.storchakacreate