[Python-checkins] r86030 - in python/branches/release27-maint: Lib/test/regrtest.py

antoine.pitrou python-checkins at python.org
Sun Oct 31 14:17:46 CET 2010


Author: antoine.pitrou
Date: Sun Oct 31 14:17:46 2010
New Revision: 86030

Log:
Merged revisions 85926 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r85926 | antoine.pitrou | 2010-10-29 13:54:38 +0200 (ven., 29 oct. 2010) | 3 lines
  
  Actually restore the original asyncore socket map by making a copy of the dict
........


Modified:
   python/branches/release27-maint/   (props changed)
   python/branches/release27-maint/Lib/test/regrtest.py

Modified: python/branches/release27-maint/Lib/test/regrtest.py
==============================================================================
--- python/branches/release27-maint/Lib/test/regrtest.py	(original)
+++ python/branches/release27-maint/Lib/test/regrtest.py	Sun Oct 31 14:17:46 2010
@@ -799,11 +799,12 @@
 
     def get_asyncore_socket_map(self):
         asyncore = sys.modules.get('asyncore')
-        return asyncore and asyncore.socket_map or {}
+        # XXX Making a copy keeps objects alive until __exit__ gets called.
+        return asyncore and asyncore.socket_map.copy() or {}
     def restore_asyncore_socket_map(self, saved_map):
         asyncore = sys.modules.get('asyncore')
         if asyncore is not None:
-            asyncore.socket_map.clear()
+            asyncore.close_all(ignore_all=True)
             asyncore.socket_map.update(saved_map)
 
     def resource_info(self):
@@ -819,9 +820,11 @@
         return self
 
     def __exit__(self, exc_type, exc_val, exc_tb):
+        saved_values = self.saved_values
+        del self.saved_values
         for name, get, restore in self.resource_info():
             current = get()
-            original = self.saved_values[name]
+            original = saved_values.pop(name)
             # Check for changes to the resource's value
             if current != original:
                 self.changed = True


More information about the Python-checkins mailing list