diff Lib/socket.py @ 29311:ed70779f6402 legacy-trunk

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__.
author Guido van Rossum <guido@python.org>
date Thu, 29 May 2003 14:36:57 +0000
parents 90342f395721
children 1e2e54821785
line wrap: on
line diff
--- a/Lib/socket.py	Thu May 29 14:30:49 2003 +0000
+++ b/Lib/socket.py	Thu May 29 14:36:57 2003 +0000
@@ -232,7 +232,11 @@
             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: