[pypy-svn] r39628 - in pypy/dist/pypy/module/rsocket: . test
fijal at codespeak.net
fijal at codespeak.net
Thu Mar 1 13:47:56 CET 2007
Author: fijal
Date: Thu Mar 1 13:47:54 2007
New Revision: 39628
Modified:
pypy/dist/pypy/module/rsocket/interp_socket.py
pypy/dist/pypy/module/rsocket/test/test_sock_app.py
Log:
(fijal, arigo, guido_w) Have errno as an argument of exception rather
than a field. A bit more cpython compliant
Modified: pypy/dist/pypy/module/rsocket/interp_socket.py
==============================================================================
--- pypy/dist/pypy/module/rsocket/interp_socket.py (original)
+++ pypy/dist/pypy/module/rsocket/interp_socket.py Thu Mar 1 13:47:54 2007
@@ -443,9 +443,11 @@
message = e.get_msg()
w_module = space.getbuiltinmodule('_socket')
w_exception_class = space.getattr(w_module, space.wrap(e.applevelerrcls))
- w_exception = space.call_function(w_exception_class, space.wrap(message))
if isinstance(e, SocketErrorWithErrno):
- space.setattr(w_exception, space.wrap('errno'), space.wrap(e.errno))
+ w_exception = space.call_function(w_exception_class, space.wrap(e.errno),
+ space.wrap(message))
+ else:
+ w_exception = space.call_function(w_exception_class, space.wrap(message))
return OperationError(w_exception_class, w_exception)
# ____________________________________________________________
Modified: pypy/dist/pypy/module/rsocket/test/test_sock_app.py
==============================================================================
--- pypy/dist/pypy/module/rsocket/test/test_sock_app.py (original)
+++ pypy/dist/pypy/module/rsocket/test/test_sock_app.py Thu Mar 1 13:47:54 2007
@@ -351,7 +351,6 @@
import socket
s = socket.socket()
-
def test_getsetsockopt(self):
import _socket as socket
import struct
@@ -423,3 +422,21 @@
foo = self.serv.accept()
raises(error, raise_error)
+
+class AppTestErrno:
+ def setup_class(cls):
+ cls.space = space
+
+ def test_errno(self):
+ from socket import socket, AF_INET, SOCK_STREAM, error
+ import errno
+ try:
+ s = socket(AF_INET, SOCK_STREAM)
+ import pypymagic
+ print pypymagic.pypy_repr(s)
+ s.accept()
+ except Exception, e:
+ assert len(e.args) == 2
+ assert e.args[0] == errno.EINVAL
+ assert isinstance(e.args[1], str)
+
More information about the Pypy-commit
mailing list