[Checkins] SVN: AccessControl/trunk/src/AccessControl/ZopeGuards.py Use a context manager, since we are Python >= 2.6.x.

Tres Seaver tseaver at palladion.com
Tue Jun 22 10:38:59 EDT 2010


Log message for revision 113763:
  Use a context manager, since we are Python >= 2.6.x.

Changed:
  U   AccessControl/trunk/src/AccessControl/ZopeGuards.py

-=-
Modified: AccessControl/trunk/src/AccessControl/ZopeGuards.py
===================================================================
--- AccessControl/trunk/src/AccessControl/ZopeGuards.py	2010-06-22 13:54:17 UTC (rev 113762)
+++ AccessControl/trunk/src/AccessControl/ZopeGuards.py	2010-06-22 14:38:59 UTC (rev 113763)
@@ -31,19 +31,15 @@
 safe_builtins = safe_builtins.copy()
 safe_builtins.update(utility_builtins)
 
-_old_filters = warnings.filters[:]
-warnings.filterwarnings('ignore', category=DeprecationWarning)
-try:
+# Allow access to unprotected attributes (don't show deprecation warning).
+with warnings.catch_warnings():
     try:
         import sets
     except ImportError:
-        sets = None
+        pass
     else:
         sets.__allow_access_to_unprotected_subobjects__ = 1
-finally:
-    warnings.filters[:] = _old_filters
 
-
 # Allow access to unprotected attributes
 string.__allow_access_to_unprotected_subobjects__ = 1
 math.__allow_access_to_unprotected_subobjects__ = 1



More information about the checkins mailing list