[pypy-svn] pypy fast-forward: Fixes in test_socket.py.

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


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

Log:	Fixes in test_socket.py. At least it does not block forever...

diff --git a/lib-python/modified-2.7.0/socket.py b/lib-python/modified-2.7.0/socket.py
--- a/lib-python/modified-2.7.0/socket.py
+++ b/lib-python/modified-2.7.0/socket.py
@@ -218,7 +218,7 @@
         Return a regular file object corresponding to the socket.  The mode
         and bufsize arguments are as for the built-in open() function."""
         self._io_refs += 1
-        return _fileobject(self._sock, mode, bufsize)
+        return _fileobject(self, mode, bufsize)
 
     def _decref_socketios(self):
         if self._io_refs > 0:
@@ -298,8 +298,10 @@
             if self._sock:
                 self.flush()
         finally:
-            if self._close:
-                self._sock.close()
+            if self._sock:
+                if self._close:
+                    self._sock.close()
+                self._sock._decref_socketios()
             self._sock = None
 
     def __del__(self):

diff --git a/lib-python/modified-2.7.0/test/test_socket.py b/lib-python/modified-2.7.0/test/test_socket.py
--- a/lib-python/modified-2.7.0/test/test_socket.py
+++ b/lib-python/modified-2.7.0/test/test_socket.py
@@ -1260,6 +1260,7 @@
             closed = False
             def flush(self): pass
             def close(self): self.closed = True
+            def _decref_socketios(self): pass
 
         # must not close unless we request it: the original use of _fileobject
         # by module socket requires that the underlying socket not be closed until


More information about the Pypy-commit mailing list