Author: Brian Kearns <bdkea...@gmail.com>
Branch: 
Changeset: r60664:466f3b01ca3d
Date: 2013-01-29 06:11 -0500
http://bitbucket.org/pypy/pypy/changeset/466f3b01ca3d/

Log:    don't raise errors on socket.close() to match cpython

diff --git a/pypy/module/_socket/interp_socket.py 
b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -181,7 +181,8 @@
         try:
             self.close()
         except SocketError, e:
-            raise converted_error(space, e)
+            # cpython doesn't return any errors on close
+            pass
 
     def connect_w(self, space, w_addr):
         """connect(address)
@@ -448,7 +449,7 @@
                 w_addr = space.w_None
             return space.newtuple([space.wrap(readlgt), w_addr])
         except SocketError, e:
-            raise converted_error(space, e)        
+            raise converted_error(space, e)
 
     @unwrap_spec(cmd=int)
     def ioctl_w(self, space, cmd, w_option):
diff --git a/pypy/module/_socket/test/test_sock_app.py 
b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -362,13 +362,14 @@
         assert isinstance(s.fileno(), int)
 
     def test_socket_close(self):
-        import _socket
+        import _socket, os
         s = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM, 0)
         fileno = s.fileno()
         assert s.fileno() >= 0
         s.close()
         assert s.fileno() < 0
         s.close()
+        raises(OSError, os.close, fileno)
 
     def test_socket_close_error(self):
         import _socket, os
@@ -376,7 +377,7 @@
             skip("Windows sockets are not files")
         s = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM, 0)
         os.close(s.fileno())
-        raises(_socket.error, s.close)
+        s.close()
 
     def test_socket_connect(self):
         import _socket, os
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to