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.

classification
Title: calendar: OverflowErrors for year == 1 and firstweekday > 0
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Make Calendar.itermonthdates() behave consistently in edge cases
View: 28292
Assigned To: belopolsky Nosy List: SilentGhost, belopolsky, mjpieters, rhettinger
Priority: normal Keywords: patch

Created on 2016-03-27 09:38 by mjpieters, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue26650.diff SilentGhost, 2016-03-27 10:38 review
Messages (3)
msg262514 - (view) Author: Martijn Pieters (mjpieters) * Date: 2016-03-27 09:38
For anything other than calendar.Calendar(0), many methods lead to OverflowError exceptions:

>>> import calendar
>>> c = calendar.Calendar(0)
>>> list(c.itermonthdays(1, 1))
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, 0, 0, 0]
>>> c = calendar.Calendar(1)
>>> list(c.itermonthdays(1, 1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mjpieters/Development/Library/buildout.python/parts/opt/lib/python2.7/calendar.py", line 188, in itermonthdays
    for date in self.itermonthdates(year, month):
  File "/Users/mjpieters/Development/Library/buildout.python/parts/opt/lib/python2.7/calendar.py", line 160, in itermonthdates
    date -= datetime.timedelta(days=days)
OverflowError: date value out of range

This echoes a similar problem with year = 9999, see issue #15421
msg262515 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2016-03-27 10:38
Here is the patch. Both this patch and the fix for #15421 might violate the documented behaviour of getting the full week's worth of dates. I wonder if that should also be documented.
msg277477 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2016-09-26 23:31
My patch for issue 28253 fixes this problem for itermonthdays2() and itermonthdays() methods.  As discussed there, fixing itermonthdates() would require changing a documented public interface.
History
Date User Action Args
2022-04-11 14:58:29adminsetgithub: 70837
2016-09-28 03:05:06belopolskylinkissue28292 dependencies
2016-09-28 03:04:31belopolskysetstatus: open -> closed
superseder: Make Calendar.itermonthdates() behave consistently in edge cases
resolution: duplicate
stage: patch review -> resolved
2016-09-26 23:31:13belopolskysetassignee: belopolsky

messages: + msg277477
nosy: + belopolsky
2016-03-27 10:38:02SilentGhostsetfiles: + issue26650.diff

type: crash -> behavior
versions: + Python 3.6
keywords: + patch
nosy: + rhettinger, SilentGhost

messages: + msg262515
stage: patch review
2016-03-27 09:38:56mjpieterscreate