summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorAN Long <aisk@users.noreply.github.com>2024-09-20 12:42:43 (GMT)
committerGitHub <noreply@github.com>2024-09-20 12:42:43 (GMT)
commit1a577729e347714eb819fa3a3a00149406c24e5e (patch)
treec4ebf550264e6c9914f6b458aef72d61bc5e3228 /Python
parentdb6eb3640a7d98db6fea17cf9da4cb14504e5571 (diff)
downloadcpython-1a577729e347714eb819fa3a3a00149406c24e5e.zip
cpython-1a577729e347714eb819fa3a3a00149406c24e5e.tar.gz
cpython-1a577729e347714eb819fa3a3a00149406c24e5e.tar.bz2
gh-111513: Improve datetime.fromtimestamp's error message (#124249)
Diffstat (limited to 'Python')
-rw-r--r--Python/pytime.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/pytime.c b/Python/pytime.c
index cd76970..2b37cd9 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -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;