[pypy-svn] r33368 - in pypy/dist/pypy/module/rsocket: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Oct 17 14:29:58 CEST 2006
Author: arigo
Date: Tue Oct 17 14:29:55 2006
New Revision: 33368
Modified:
pypy/dist/pypy/module/rsocket/rsocket.py
pypy/dist/pypy/module/rsocket/test/test_rsocket.py
Log:
connect_ex() return value fix.
Modified: pypy/dist/pypy/module/rsocket/rsocket.py
==============================================================================
--- pypy/dist/pypy/module/rsocket/rsocket.py (original)
+++ pypy/dist/pypy/module/rsocket/rsocket.py Tue Oct 17 14:29:55 2006
@@ -348,6 +348,7 @@
class RSocket(object):
"""RPython-level socket object.
"""
+ _mixin_ = True # for interp_socket.py
def __init__(self, family=_c.AF_INET, type=_c.SOCK_STREAM, proto=0):
"""Create a new socket."""
@@ -413,7 +414,10 @@
def connect_ex(self, address):
"""This is like connect(address), but returns an error code (the errno
value) instead of raising an exception when an error occurs."""
- return _c.socketconnect(self.fd, byref(address.addr), address.addrlen)
+ res = _c.socketconnect(self.fd, byref(address.addr), address.addrlen)
+ if res != 0:
+ res = _c.geterrno()
+ return res
def fileno(self):
return self.fd
Modified: pypy/dist/pypy/module/rsocket/test/test_rsocket.py
==============================================================================
--- pypy/dist/pypy/module/rsocket/test/test_rsocket.py (original)
+++ pypy/dist/pypy/module/rsocket/test/test_rsocket.py Tue Oct 17 14:29:55 2006
@@ -175,3 +175,8 @@
if addr.get_host() == '134.99.112.214':
found = True
assert found, lst
+
+def test_connect_ex():
+ s = RSocket()
+ err = s.connect_ex(s.getsockname()) # should not work
+ assert err == errno.ECONNREFUSED
More information about the Pypy-commit
mailing list