[pypy-svn] r20879 - in pypy/dist/pypy: module/_socket translator/c/src translator/c/test
nik at codespeak.net
nik at codespeak.net
Thu Dec 8 11:53:59 CET 2005
Author: nik
Date: Thu Dec 8 11:53:57 2005
New Revision: 20879
Modified:
pypy/dist/pypy/module/_socket/interp_socket.py
pypy/dist/pypy/translator/c/src/ll__socket.h
pypy/dist/pypy/translator/c/test/test_ext__socket.py
Log:
(ale, nik)
error handling for socket creation complete (but convoluted).
Modified: pypy/dist/pypy/module/_socket/interp_socket.py
==============================================================================
--- pypy/dist/pypy/module/_socket/interp_socket.py (original)
+++ pypy/dist/pypy/module/_socket/interp_socket.py Thu Dec 8 11:53:57 2005
@@ -619,8 +619,10 @@
try:
fd = rsocket.newsocket(family, type, proto)
- except socket.error, e:
+ except socket.error, e: # On untranslated PyPy
raise wrap_socketerror(space, e)
+ except OSError, e: # On translated PyPy
+ raise w_get_socketerror(space, e.strerror, e.errno)
# XXX If we want to support subclassing the socket type we will need
# something along these lines. But allocate_instance is only defined
# on the standard object space, so this is not really correct.
Modified: pypy/dist/pypy/translator/c/src/ll__socket.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll__socket.h (original)
+++ pypy/dist/pypy/translator/c/src/ll__socket.h Thu Dec 8 11:53:57 2005
@@ -89,6 +89,9 @@
if (fd < 0)
#endif
{
+ // Raise OSError instead of socket.error for convenience.
+ // XXX For some reason the errno attribute of the OSError is not set
+ // at interpreter level. Investigate ...
RPYTHON_RAISE_OSERROR(errno);
}
}
Modified: pypy/dist/pypy/translator/c/test/test_ext__socket.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_ext__socket.py (original)
+++ pypy/dist/pypy/translator/c/test/test_ext__socket.py Thu Dec 8 11:53:57 2005
@@ -80,16 +80,12 @@
def test_newsocket_error():
from pypy.module._socket.rpython import rsocket
- tests = [(1001, _socket.SOCK_STREAM, 0)]
+ tests = [
+ (1001, _socket.SOCK_STREAM, 0),
+ (_socket.AF_INET, 555555, 0),
+ ]
def does_stuff(family, type, protocol):
return rsocket.newsocket(family, type, protocol)
f1 = compile(does_stuff, [int, int, int])
for args in tests:
- try:
- f1(*args)
- except OSError, ex:
- try:
- import socket
- socket.socket(*args)
- except socket.error, ex_socket:
- assert ex_socket.args[0] == ex.errno
+ py.test.raises(OSError, f1, *args)
More information about the Pypy-commit
mailing list