10000 bpo-36004: Add date.fromisocalendar by pganssle · Pull Request #11888 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-36004: Add date.fromisocalendar #11888

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

Merged
merged 14 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use MINYEAR and MAXYEAR in bounds checks
  • Loading branch information
pganssle committed Apr 29, 2019
commit c8444b70f18a6fb9a157c942a07d61f6c3aea8a0
2 changes: 1 addition & 1 deletion Lib/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ def fromisocalendar(cls, year, week, day):

This is the inverse of the date.isocalendar() function"""
# Year is bounded this way because 9999-12-31 is (9999, 52, 5)
if not 0 < year < 10000:
if not MINYEAR <= year <= MAXYEAR:
raise ValueError(f"Year is out of range: {year}")

if not 0 < week < 53:
Expand Down
2 changes: 1 addition & 1 deletion Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3024,7 +3024,7 @@ date_fromisocalendar(PyObject *cls, PyObject *args, PyObject *kw)
}

// Year is bounded to 0 < year < 10000 because 9999-12-31 is (9999, 52, 5)
if (year <= 0 || year >= 10000) {
if (year < MINYEAR || year > MAXYEAR) {
PyErr_Format(PyExc_ValueError, "Year is out of range: %d", year);
return NULL;
}
Expand Down
0