diff Lib/socket.py @ 64334:4f2905ea7809 2.7

Issue #808164: Fixed socket.close to avoid references to globals, to avoid issues when socket.close is called from a __del__ method.
author Daniel Stutzbach <daniel@stutzbachenterprises.com>
date Tue, 31 Aug 2010 20:29:39 +0000
parents 72e3e85bac8b
children af414b29d467
line wrap: on
line diff
--- a/Lib/socket.py	Mon Aug 30 18:10:03 2010 +0000
+++ b/Lib/socket.py	Tue Aug 31 20:29:39 2010 +0000
@@ -189,7 +189,9 @@
         for method in _delegate_methods:
             setattr(self, method, getattr(_sock, method))
 
-    def close(self):
+    def close(self, _closedsocket=_closedsocket,
+              _delegate_methods=_delegate_methods, setattr=setattr):
+        # This function should not reference any globals. See issue #808164.
         self._sock = _closedsocket()
         dummy = self._sock._dummy
         for method in _delegate_methods: