summaryrefslogtreecommitdiff
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-08 18:11:36 +0000
committerGuido van Rossum <guido@python.org>2002-08-08 18:11:36 +0000
commit715f970969e7acb4ba66b6369ce8bd9d88fc6ef1 (patch)
treef0c081160c798fe2f2070d612fd3c72eebdb0fa8 /Lib/socket.py
parent48b7969af8aa537c306eeec8d22235f360c229ed (diff)
downloadcpython-git-715f970969e7acb4ba66b6369ce8bd9d88fc6ef1.tar.gz
The _socketobject class has no need for a __del__ method: all it did was
to delete the reference to self._sock, and the regular destructor will do that just fine. This made some hacks in close() unnecessary. The _fileobject class still has a __del__ method, because it must flush.
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 0daeadcb34..3611c439c7 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -136,30 +136,26 @@ _socketmethods = (
'recv', 'recvfrom', 'send', 'sendall', 'sendto', 'setblocking',
'settimeout', 'gettimeout', 'shutdown')
+class _closedsocket(object):
+ __slots__ = []
+ def __getattr__(self, name):
+ raise error(9, 'Bad file descriptor')
+
class _socketobject(object):
__doc__ = _realsocket.__doc__
__slots__ = ["_sock"]
- class _closedsocket(object):
- __slots__ = []
- def __getattr__(self, name):
- raise error(9, 'Bad file descriptor')
-
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
if _sock is None:
_sock = _realsocket(family, type, proto)
self._sock = _sock
def close(self):
- # Avoid referencing globals here
- self._sock = self.__class__._closedsocket()
+ self._sock = _closedsocket()
close.__doc__ = _realsocket.close.__doc__
- def __del__(self):
- self.close()
-
def accept(self):
sock, addr = self._sock.accept()
return _socketobject(_sock=sock), addr