Skip to content

Commit c8444b7

Browse files
committed
Use MINYEAR and MAXYEAR in bounds checks
1 parent c269a5c commit c8444b7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Lib/datetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ def fromisocalendar(cls, year, week, day):
890890
891891
This is the inverse of the date.isocalendar() function"""
892892
# Year is bounded this way because 9999-12-31 is (9999, 52, 5)
893-
if not 0 < year < 10000:
893+
if not MINYEAR <= year <= MAXYEAR:
894894
raise ValueError(f"Year is out of range: {year}")
895895

896896
if not 0 < week < 53:

Modules/_datetimemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3024,7 +3024,7 @@ date_fromisocalendar(PyObject *cls, PyObject *args, PyObject *kw)
30243024
}
30253025

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

0 commit comments

Comments
 (0)