[pypy-svn] r34455 - in pypy/dist/pypy/module: rctime select

ac at codespeak.net ac at codespeak.net
Fri Nov 10 12:27:22 CET 2006


Author: ac
Date: Fri Nov 10 12:27:21 2006
New Revision: 34455

Modified:
   pypy/dist/pypy/module/rctime/app_time.py
   pypy/dist/pypy/module/select/app_select.py
Log:
Do some typechecking on the arguments to time.sleep and select.select.

Modified: pypy/dist/pypy/module/rctime/app_time.py
==============================================================================
--- pypy/dist/pypy/module/rctime/app_time.py	(original)
+++ pypy/dist/pypy/module/rctime/app_time.py	Fri Nov 10 12:27:21 2006
@@ -46,6 +46,8 @@
     
         Delay execution for a given number of seconds.  The argument may be
         a floating point number for subsecond precision."""
+        if secs is None:
+            raise TypeError('a float is required')
         select([], [], [], secs)
 
 

Modified: pypy/dist/pypy/module/select/app_select.py
==============================================================================
--- pypy/dist/pypy/module/select/app_select.py	(original)
+++ pypy/dist/pypy/module/select/app_select.py	Fri Nov 10 12:27:21 2006
@@ -56,7 +56,10 @@
     for fd, mask in polldict.iteritems():
         p.register(fd, mask)
     if timeout is not None:
-        ret = dict(p.poll(int(timeout * 1000)))
+        if (not hasattr(timeout, '__int__') and
+            not hasattr(timeout, '__float__')):
+            raise TypeError('timeout must be a float or None')
+        ret = dict(p.poll(int(float(timeout) * 1000)))
     else:
         ret = dict(p.poll())
 


More information about the pypy-svn mailing list