[pypy-svn] r46819 - in pypy/dist/pypy/rlib: . test

arigo at codespeak.net arigo at codespeak.net
Sat Sep 22 14:05:04 CEST 2007


Author: arigo
Date: Sat Sep 22 14:05:02 2007
New Revision: 46819

Modified:
   pypy/dist/pypy/rlib/rsocket.py
   pypy/dist/pypy/rlib/test/test_rsocket.py
Log:
test_rsocket passes on Windows.


Modified: pypy/dist/pypy/rlib/rsocket.py
==============================================================================
--- pypy/dist/pypy/rlib/rsocket.py	(original)
+++ pypy/dist/pypy/rlib/rsocket.py	Sat Sep 22 14:05:02 2007
@@ -569,17 +569,18 @@
         def _select(self, for_writing):
             """Returns 0 when reading/writing is possible,
             1 when timing out and -1 on error."""
-            if self.timeout <= 0.0 or self.fd == _c.INVALID_SOCKET:
+            timeout = self.timeout
+            if timeout <= 0.0 or self.fd == _c.INVALID_SOCKET:
                 # blocking I/O or no socket.
                 return 0
             tv = rffi.make(_c.timeval)
-            rffi.setintfield(tv, 'tv_sec', int(self.timeout))
-            rffi.setintfield(tv, 'tv_usec', int((self.timeout-int(self.timeout))
-                                                * 1000000))
+            rffi.setintfield(tv, 'c_tv_sec', int(timeout))
+            rffi.setintfield(tv, 'c_tv_usec', int((timeout-int(timeout))
+                                                  * 1000000))
             fds = rffi.make(_c.fd_set)
-            rffi.setintfield(fds, 'fd_count', 1)
-            fds.fd_array[0] = rffi.cast(socketfd_type, self.fd)
-            null = lltype.nullptr(fd_set)
+            rffi.setintfield(fds, 'c_fd_count', 1)
+            fds.c_fd_array[0] = rffi.cast(_c.socketfd_type, self.fd)
+            null = lltype.nullptr(_c.fd_set)
             if for_writing:
                 n = _c.select(self.fd + 1, null, fds, null, tv)
             else:

Modified: pypy/dist/pypy/rlib/test/test_rsocket.py
==============================================================================
--- pypy/dist/pypy/rlib/test/test_rsocket.py	(original)
+++ pypy/dist/pypy/rlib/test/test_rsocket.py	Sat Sep 22 14:05:02 2007
@@ -334,10 +334,14 @@
     assert inet_ntoa('\x01\x02\x03\x04') == '1.2.3.4'
 
 def test_inet_pton():
+    if not hasattr(rsocket, 'inet_pton'):
+        py.test.skip("no inet_pton()")
     assert inet_pton(AF_INET, '1.2.3.5') == '\x01\x02\x03\x05'
     py.test.raises(SocketError, inet_pton, AF_INET, '127.0.0.256')
 
 def test_inet_ntop():
+    if not hasattr(rsocket, 'inet_ntop'):
+        py.test.skip("no inet_ntop()")
     assert inet_ntop(AF_INET, '\x01\x02\x03\x05') == '1.2.3.5'
 
 class TestTCP:



More information about the Pypy-commit mailing list