Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calendar: OverflowErrors for year == 1 and firstweekday > 0 #70837

Closed
mjpieters mannequin opened this issue Mar 27, 2016 · 3 comments
Closed

calendar: OverflowErrors for year == 1 and firstweekday > 0 #70837

mjpieters mannequin opened this issue Mar 27, 2016 · 3 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@mjpieters
Copy link
Mannequin

mjpieters mannequin commented Mar 27, 2016

BPO 26650
Nosy @rhettinger, @mjpieters, @abalkin
Superseder
  • bpo-28292: Make Calendar.itermonthdates() behave consistently in edge cases
  • Files
  • issue26650.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/abalkin'
    closed_at = <Date 2016-09-28.03:04:31.303>
    created_at = <Date 2016-03-27.09:38:56.897>
    labels = ['type-bug', 'library']
    title = 'calendar: OverflowErrors for year == 1 and firstweekday > 0'
    updated_at = <Date 2016-09-28.03:04:31.302>
    user = 'https://github.com/mjpieters'

    bugs.python.org fields:

    activity = <Date 2016-09-28.03:04:31.302>
    actor = 'belopolsky'
    assignee = 'belopolsky'
    closed = True
    closed_date = <Date 2016-09-28.03:04:31.303>
    closer = 'belopolsky'
    components = ['Library (Lib)']
    creation = <Date 2016-03-27.09:38:56.897>
    creator = 'mjpieters'
    dependencies = []
    files = ['42305']
    hgrepos = []
    issue_num = 26650
    keywords = ['patch']
    message_count = 3.0
    messages = ['262514', '262515', '277477']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'mjpieters', 'belopolsky', 'SilentGhost']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '28292'
    type = 'behavior'
    url = 'https://bugs.python.org/issue26650'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    @mjpieters
    Copy link
    Mannequin Author

    mjpieters mannequin commented Mar 27, 2016

    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 bpo-15421

    @mjpieters mjpieters mannequin added type-crash A hard crash of the interpreter, possibly with a core dump stdlib Python modules in the Lib dir labels Mar 27, 2016
    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Mar 27, 2016

    Here is the patch. Both this patch and the fix for bpo-15421 might violate the documented behaviour of getting the full week's worth of dates. I wonder if that should also be documented.

    @SilentGhost SilentGhost mannequin added type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Mar 27, 2016
    @abalkin
    Copy link
    Member

    abalkin commented Sep 26, 2016

    My patch for bpo-28253 fixes this problem for itermonthdays2() and itermonthdays() methods. As discussed there, fixing itermonthdates() would require changing a documented public interface.

    @abalkin abalkin self-assigned this Sep 26, 2016
    @abalkin abalkin closed this as completed Sep 28, 2016
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant