[pypy-svn] pypy fast-forward: Let the tests pass with -A on top of CPython.

amauryfa commits-noreply at bitbucket.org
Tue Jan 11 13:08:15 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40576:ddf625bbef8c
Date: 2011-01-11 11:34 +0100
http://bitbucket.org/pypy/pypy/changeset/ddf625bbef8c/

Log:	Let the tests pass with -A on top of CPython. s.fileno() on a closed
	socket has never raised an error.

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
@@ -351,14 +351,10 @@
         import _socket, errno
         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()
-        try:
-            s.fileno()
-        except _socket.error, ex:
-            assert ex.args[0], errno.EBADF
-        else:
-            assert 0
 
     def test_socket_close_error(self):
         import _socket, os
@@ -657,8 +653,11 @@
         import errno
         try:
             s = socket(AF_INET, SOCK_STREAM)
-            import __pypy__
-            print __pypy__.internal_repr(s)
+            try:
+                import __pypy__
+                print __pypy__.internal_repr(s)
+            except ImportError:
+                pass
             s.accept()
         except Exception, e:
             assert len(e.args) == 2

diff --git a/pypy/rlib/rsocket.py b/pypy/rlib/rsocket.py
--- a/pypy/rlib/rsocket.py
+++ b/pypy/rlib/rsocket.py
@@ -824,10 +824,7 @@
                                SocketClass=SocketClass)
         
     def fileno(self):
-        fd = self.fd
-        if _c.invalid_socket(fd):
-            raise RSocketError("socket already closed")
-        return fd
+        return self.fd
 
     def getpeername(self):
         """Return the address of the remote endpoint."""


More information about the Pypy-commit mailing list