[pypy-commit] pypy default: fix test_connect_with_timeout_fail on win32

bdkearns noreply at buildbot.pypy.org
Tue Apr 22 22:12:31 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r70871:559dc95b2b7d
Date: 2014-04-22 13:11 -0700
http://bitbucket.org/pypy/pypy/changeset/559dc95b2b7d/

Log:	fix test_connect_with_timeout_fail on win32

diff --git a/rpython/rlib/_rsocket_rffi.py b/rpython/rlib/_rsocket_rffi.py
--- a/rpython/rlib/_rsocket_rffi.py
+++ b/rpython/rlib/_rsocket_rffi.py
@@ -623,7 +623,7 @@
 
 if WIN32:
     WSAData = cConfig.WSAData
-    WSAStartup = external('WSAStartup', [rffi.INT, lltype.Ptr(WSAData)],
+    WSAStartup = external('WSAStartup', [rwin32.WORD, lltype.Ptr(WSAData)],
                           rffi.INT)
 
     WSAGetLastError = external('WSAGetLastError', [], rffi.INT)
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -33,9 +33,11 @@
     from rpython.rlib import rwin32
     def rsocket_startup():
         wsadata = lltype.malloc(_c.WSAData, flavor='raw', zero=True)
-        res = _c.WSAStartup(1, wsadata)
-        lltype.free(wsadata, flavor='raw')
-        assert res == 0
+        try:
+            res = _c.WSAStartup(0x0101, wsadata)
+            assert res == 0
+        finally:
+            lltype.free(wsadata, flavor='raw')
 else:
     def rsocket_startup():
         pass
diff --git a/rpython/rlib/test/test_rsocket.py b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -345,12 +345,13 @@
     err = s.connect_ex(INETAddress('0.0.0.0', 0))   # should not work
     if errcodesok:
         assert err in (errno.ECONNREFUSED, errno.EADDRNOTAVAIL)
+    s.close()
 
 def test_connect_with_timeout_fail():
     s = RSocket()
     s.settimeout(0.1)
     with py.test.raises(SocketTimeout):
-        s.connect(INETAddress('240.240.240.240', 12345))
+        s.connect(INETAddress('10.10.10.10', 12345))
     s.close()
 
 def test_connect_with_timeout_succeed():


More information about the pypy-commit mailing list