mirror of https://github.com/python/cpython.git
gh-111513: Improve datetime.fromtimestamp's error message (#124249)
This commit is contained in:
parent
db6eb3640a
commit
1a577729e3
|
@ -0,0 +1 @@
|
||||||
|
Improve the error message that may be raised by :meth:`datetime.date.fromtimestamp`.
|
|
@ -387,6 +387,10 @@ pytime_object_to_denominator(PyObject *obj, time_t *sec, long *numerator,
|
||||||
*sec = _PyLong_AsTime_t(obj);
|
*sec = _PyLong_AsTime_t(obj);
|
||||||
*numerator = 0;
|
*numerator = 0;
|
||||||
if (*sec == (time_t)-1 && PyErr_Occurred()) {
|
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 -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue