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:
Stan Ulbrych
2025-03-21 03:47:09 +00:00
committed by GitHub
parent e3564689a5
commit e0fda794fa
4 changed files with 20 additions and 6 deletions

View File

@@ -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;