]> granicus.if.org Git - python/commitdiff
Issue #808164: Fixed socket.close to avoid references to globals, to
authorDaniel Stutzbach <daniel@stutzbachenterprises.com>
Tue, 31 Aug 2010 20:29:39 +0000 (20:29 +0000)
committerDaniel Stutzbach <daniel@stutzbachenterprises.com>
Tue, 31 Aug 2010 20:29:39 +0000 (20:29 +0000)
avoid issues when socket.close is called from a __del__ method.

Lib/socket.py
Misc/NEWS

index 9b4bedaafbede063a6fb7288d4db2c71cf150c78..9ed2de9132bbaf7a5b9cd90c50ae933e58986c3a 100644 (file)
@@ -189,7 +189,9 @@ class _socketobject(object):
         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:
index 1fa15224e2f7867e58cad33b1d7a718997c52639..31669cf1a9b83534ee6fa18ebc8bc9617cc385e4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -33,6 +33,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #808164: Fixed socket.close to avoid references to globals, to
+  avoid issues when socket.close is called from a __del__ method.
+
 - Issue #8797: urllib2 does a retry for Basic Authentication failure instead of
   falling into recursion.