[pypy-svn] r20877 - in pypy/dist/pypy/translator/c: src test

nik at codespeak.net nik at codespeak.net
Thu Dec 8 11:16:16 CET 2005


Author: nik
Date: Thu Dec  8 11:16:14 2005
New Revision: 20877

Modified:
   pypy/dist/pypy/translator/c/src/ll__socket.h
   pypy/dist/pypy/translator/c/test/test_ext__socket.py
Log:
(ale, nik)

for now raise OSError from C code on socket errors. more sophisticated
error tests.


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:16:14 2005
@@ -89,7 +89,7 @@
     if (fd < 0)
 #endif
     {
-      return -1; 
+        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:16:14 2005
@@ -80,9 +80,16 @@
 
 def test_newsocket_error():
     from pypy.module._socket.rpython import rsocket
-    def does_stuff():
-        return rsocket.newsocket(1001, _socket.SOCK_STREAM, 0)
-    f1 = compile(does_stuff, [])
-    res = f1()
-    assert res == -1
-
+    tests = [(1001, _socket.SOCK_STREAM, 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



More information about the Pypy-commit mailing list