diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-28 00:26:47 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-28 00:26:47 (GMT) |
commit | 95e9cef6f023a1cf365f2f02775badb3a6ac0d82 (patch) | |
tree | 721cb2ab9fbba707888bc7e90b49758ffd5156ed /Modules/timemodule.c | |
parent | b7df3144ef14ec50650dfd47da4ba09ee0bc674c (diff) | |
download | cpython-95e9cef6f023a1cf365f2f02775badb3a6ac0d82.zip cpython-95e9cef6f023a1cf365f2f02775badb3a6ac0d82.tar.gz cpython-95e9cef6f023a1cf365f2f02775badb3a6ac0d82.tar.bz2 |
Issue #22117: Write unit tests for _PyTime_AsTimeval()
* _PyTime_AsTimeval() now ensures that tv_usec is always positive
* _PyTime_AsTimespec() now ensures that tv_nsec is always positive
* _PyTime_AsTimeval() now returns an integer on overflow instead of raising an
exception
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 880f3d2..21e6f43 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -1405,8 +1405,11 @@ pysleep(_PyTime_t secs) do { #ifndef MS_WINDOWS - if (_PyTime_AsTimeval(secs, &timeout, _PyTime_ROUND_UP) < 0) + if (_PyTime_AsTimeval(secs, &timeout, _PyTime_ROUND_UP) < 0) { + PyErr_SetString(PyExc_OverflowError, + "delay doesn't fit into C timeval"); return -1; + } Py_BEGIN_ALLOW_THREADS err = select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout); |