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 belopolsky
Recipients belopolsky,, rhettinger, serhiy.storchaka, xiang.zhang
Date 2016-09-26.18:34:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> itermonthdates() is documented public method

The current documentation is an impossibility:

"The iterator will yield values and will always iterate through complete weeks, so it will yield dates outside the specified

The current implementation deals with this impossibility differently for months (9999, 12) and (1, 1).  In the first case, the iterators stops on an out of bounds date:

>>> list(calendar.Calendar().itermonthdates(9999, 12))[-1], 12, 31)
>>> list(calendar.Calendar().itermonthdates(9999, 12))[-1].weekday()

but in the second, it raises the OverflowError:

>>> next(calendar.Calendar(1).itermonthdates(1, 1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "", line 160, in itermonthdates
    date -= datetime.timedelta(days=days)
OverflowError: date value out of range

Returning dummy instances instead of in these cases will only make debugging harder for the users of .itermonthdates().  Sooner or later they would want to do something the returned value that the dummy won't support.  If you are willing to sacrifice the "will yield values" for "will always iterate through complete weeks", I would make it yield None for out of bounds values and require the caller to deal with this possibility right away.

A better solution would be to simply raise OverflowError whenever the range of itermonthdates() does not fit within [date.min, date.max].
Date User Action Args
2016-09-26 18:34:26belopolskysetrecipients: + belopolsky, rhettinger, serhiy.storchaka, xiang.zhang,
2016-09-26 18:34:26belopolskysetmessageid: <>
2016-09-26 18:34:26belopolskylinkissue28253 messages
2016-09-26 18:34:26belopolskycreate