summaryrefslogtreecommitdiffstats
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-05-29 14:36:57 (GMT)
committerGuido van Rossum <guido@python.org>2003-05-29 14:36:57 (GMT)
commit65f8cedd4a9820e5d069ece0194b7da0b1e4e33c (patch)
tree007ee4a343cb28ccfe79f026a0821a13c77ca55e /Lib/socket.py
parentbb1861a996f659621a3d9de875027679ce1926eb (diff)
downloadcpython-65f8cedd4a9820e5d069ece0194b7da0b1e4e33c.zip
cpython-65f8cedd4a9820e5d069ece0194b7da0b1e4e33c.tar.gz
cpython-65f8cedd4a9820e5d069ece0194b7da0b1e4e33c.tar.bz2
I saw errors from _fileobject.__del__ about missing self._sock. This
can happen if __init__ doesn't complete. Fix it by adding a try/except to __del__.
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 9598f99..b95c372 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -232,7 +232,11 @@ class _fileobject(object):
self._sock = None
def __del__(self):
- self.close()
+ try:
+ self.close()
+ except:
+ # close() may fail if __init__ didn't complete
+ pass
def flush(self):
if self._wbuf: