Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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