[pypy-commit] pypy default: raise an IOError when sleeping for negative time (Issue922)

timo_jbo noreply at buildbot.pypy.org
Wed Oct 26 03:03:22 CEST 2011


Author: Timo Paulssen <timonator at perpetuum-immobile.de>
Branch: 
Changeset: r48467:b5bd720602fb
Date: 2011-10-26 03:00 +0200
http://bitbucket.org/pypy/pypy/changeset/b5bd720602fb/

Log:	raise an IOError when sleeping for negative time (Issue922)

diff --git a/pypy/module/rctime/interp_time.py b/pypy/module/rctime/interp_time.py
--- a/pypy/module/rctime/interp_time.py
+++ b/pypy/module/rctime/interp_time.py
@@ -245,6 +245,9 @@
 if sys.platform != 'win32':
     @unwrap_spec(secs=float)
     def sleep(space, secs):
+        if secs < 0:
+            raise space.OperationError(space.w_IOError,
+                                       space.wrap("Invalid argument: negative time in sleep"))
         pytime.sleep(secs)
 else:
     from pypy.rlib import rwin32
@@ -265,6 +268,9 @@
                                    OSError(EINTR, "sleep() interrupted"))
     @unwrap_spec(secs=float)
     def sleep(space, secs):
+        if secs < 0:
+            raise space.OperationError(space.w_IOError,
+                                       space.wrap("Invalid argument: negative time in sleep"))
         # as decreed by Guido, only the main thread can be
         # interrupted.
         main_thread = space.fromcache(State).main_thread


More information about the pypy-commit mailing list