[issue28253] calendar.prcal(9999) output has a problem
Serhiy Storchaka
report at bugs.python.org
Fri Sep 23 04:51:31 EDT 2016
Serhiy Storchaka added the comment:
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/calendar.py", line 318, in prmonth
print(self.formatmonth(theyear, themonth, w, l), end=' ')
File "/home/serhiy/py/cpython-3.6/Lib/calendar.py", line 331, in formatmonth
for week in self.monthdays2calendar(theyear, themonth):
File "/home/serhiy/py/cpython-3.6/Lib/calendar.py", line 211, in monthdays2calendar
days = list(self.itermonthdays2(year, month))
File "/home/serhiy/py/cpython-3.6/Lib/calendar.py", line 179, in itermonthdays2
for date in self.itermonthdates(year, month):
File "/home/serhiy/py/cpython-3.6/Lib/calendar.py", line 162, in itermonthdates
date -= datetime.timedelta(days=days)
OverflowError: date value out of range
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28253>
_______________________________________
More information about the Python-bugs-list
mailing list