From 65f8cedd4a9820e5d069ece0194b7da0b1e4e33c Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 29 May 2003 14:36:57 +0000 Subject: [PATCH] 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__. --- Lib/socket.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/socket.py b/Lib/socket.py index 9598f99fc5f..b95c372da5f 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: