gh-70647: Raise a more informative error for when date is out of range (GH-131335)
More informative error messages mean less debugging what went wrong.
This commit is contained in:
@@ -664,7 +664,8 @@ check_date_args(int year, int month, int day)
|
||||
int dim = days_in_month(year, month);
|
||||
if (day < 1 || day > dim) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"day must be in 1..%d, not %d", dim, day);
|
||||
"day %i must be in range 1..%d for month %i in year %i",
|
||||
day, dim, month, year);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user