diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-03 20:40:09 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-03 20:40:09 (GMT) |
commit | 5accbdb8123a814d9a602e7bb640ad7f0e953f54 (patch) | |
tree | 469bbd951bbda9c7c542459a6dc76e2aea1bfd74 /Lib/io.py | |
parent | d2ef864f819ba9b3ef834e190491829bbb00b554 (diff) | |
download | cpython-5accbdb8123a814d9a602e7bb640ad7f0e953f54.zip cpython-5accbdb8123a814d9a602e7bb640ad7f0e953f54.tar.gz cpython-5accbdb8123a814d9a602e7bb640ad7f0e953f54.tar.bz2 |
Make sure socket.close() doesn't interfere with socket.makefile().
If a makefile()-generated object is open and its parent socket is
closed, the parent socket should remain open until the child is
closed, too. The code to support this is moderately complex and
requires one extra slots in the socket object.
This change fixes httplib so that several urllib2net test cases pass
again.
Add SocketCloser class to socket.py, which encapsulates the
refcounting logic for sockets after makefile() has been called.
Move SocketIO class from io module to socket module. It's only use is
to implement the raw I/O methods on top of a socket to support
makefile().
Add unittests to test_socket to cover various patterns of close and
makefile.
Diffstat (limited to 'Lib/io.py')
-rw-r--r-- | Lib/io.py | 28 |
1 files changed, 0 insertions, 28 deletions
@@ -442,34 +442,6 @@ class FileIO(_fileio._FileIO, RawIOBase): return self._mode -class SocketIO(RawIOBase): - - """Raw I/O implementation for stream sockets.""" - - # XXX More docs - - def __init__(self, sock, mode): - assert mode in ("r", "w", "rw") - RawIOBase.__init__(self) - self._sock = sock - self._mode = mode - - def readinto(self, b): - return self._sock.recv_into(b) - - def write(self, b): - return self._sock.send(b) - - def readable(self): - return "r" in self._mode - - def writable(self): - return "w" in self._mode - - def fileno(self): - return self._sock.fileno() - - class BufferedIOBase(IOBase): """Base class for buffered IO objects. |