[pypy-svn] r77128 - in pypy/branch/rsocket-improvements/pypy/module/select: . test

fijal at codespeak.net fijal at codespeak.net
Thu Sep 16 23:26:14 CEST 2010


Author: fijal
Date: Thu Sep 16 23:26:13 2010
New Revision: 77128

Modified:
   pypy/branch/rsocket-improvements/pypy/module/select/interp_select.py
   pypy/branch/rsocket-improvements/pypy/module/select/test/test_select.py
Log:
A test and a "fix". It's debatable whether it's a bug or not, but someone
complained.


Modified: pypy/branch/rsocket-improvements/pypy/module/select/interp_select.py
==============================================================================
--- pypy/branch/rsocket-improvements/pypy/module/select/interp_select.py	(original)
+++ pypy/branch/rsocket-improvements/pypy/module/select/interp_select.py	Thu Sep 16 23:26:13 2010
@@ -54,14 +54,11 @@
         if space.is_w(w_timeout, space.w_None):
             timeout = -1
         else:
-            # rationale for computing directly integer, instead
-            # of float + math.cell is that
-            # we have for free overflow check and noone really
-            # cares (since CPython does not try too hard to have
-            # a ceiling of value)
+            # we want to be compatible with cpython and also accept things
+            # that can be casted to integer (I think)
             try:
                 # compute the integer
-                timeout = space.int_w(w_timeout)
+                timeout = space.int_w(space.int(w_timeout))
             except (OverflowError, ValueError):
                 raise OperationError(space.w_ValueError,
                                      space.wrap("math range error"))

Modified: pypy/branch/rsocket-improvements/pypy/module/select/test/test_select.py
==============================================================================
--- pypy/branch/rsocket-improvements/pypy/module/select/test/test_select.py	(original)
+++ pypy/branch/rsocket-improvements/pypy/module/select/test/test_select.py	Thu Sep 16 23:26:13 2010
@@ -210,6 +210,14 @@
         assert len(res[2]) == 0
         assert res[0][0] == res[1][0]
 
+    def test_poll(self):
+        import select
+        class A(object):
+            def __int__(self):
+                return 3
+        
+        select.poll().poll(A()) # assert did not crash
+
 class AppTestSelectWithPipes(_AppTestSelect):
     "Use a pipe to get pairs of file descriptors"
     def setup_class(cls):
@@ -275,4 +283,3 @@
         s1, addr2 = cls.sock.accept()
 
         return s1, s2
-



More information about the Pypy-commit mailing list