mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-111513: Improve datetime.fromtimestamp's error message (#124249)
This commit is contained in:
parent
db6eb3640a
commit
1a577729e3
2 changed files with 5 additions and 0 deletions
|
@ -387,6 +387,10 @@ pytime_object_to_denominator(PyObject *obj, time_t *sec, long *numerator,
|
|||
*sec = _PyLong_AsTime_t(obj);
|
||||
*numerator = 0;
|
||||
if (*sec == (time_t)-1 && PyErr_Occurred()) {
|
||||
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"argument must be int or float, not %T", obj);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue