[issue12459] time.sleep(-1.0) behaviour

STINNER Victor report at bugs.python.org
Fri Jul 1 11:33:22 CEST 2011


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

I think that time.sleep() should behave as select.select() (issue #11757, commit 3982be773b54) and signal.sigtimedwait(): raise a ValueError if the timeout is negative. A good reason to always raise an error is that floatsleep() has different implementations. Especially, the select() implementation behaves differently depending on the platform: negative timeout raises an error (select.error(22, 'Invalid argument')) or returns immediatly.

Attached patch raises an error if the time length is negative. It avoids the integer overflow in the Windows implementation.

----------
keywords: +patch
nosy: +haypo
Added file: http://bugs.python.org/file22533/sleep_negative.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12459>
_______________________________________


More information about the Python-bugs-list mailing list