jinja2.sandbox should not warn on 2.6 any more.
authorArmin Ronacher <armin.ronacher@active-4.com>
Thu, 19 Feb 2009 18:57:01 +0000 (19:57 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Thu, 19 Feb 2009 18:57:01 +0000 (19:57 +0100)
--HG--
branch : trunk

jinja2/sandbox.py

index c29bdea27037eb46d3d55e3a0c52a5e091be3c3e..f93219b2552d3958920ca4d73b20a16c3a16eea6 100644 (file)
@@ -31,14 +31,27 @@ UNSAFE_FUNCTION_ATTRIBUTES = set(['func_closure', 'func_code', 'func_dict',
 UNSAFE_METHOD_ATTRIBUTES = set(['im_class', 'im_func', 'im_self'])
 
 
+import warnings
+
+# make sure we don't warn in python 2.6 about stuff we don't care about
+warnings.filterwarnings('ignore', 'the sets module', DeprecationWarning,
+                        module='jinja2.sandbox')
+
+
 from collections import deque
-from sets import Set, ImmutableSet
 from UserDict import UserDict, DictMixin
 from UserList import UserList
-_mutable_set_types = (ImmutableSet, Set, set)
+_mutable_set_types = (set,)
 _mutable_mapping_types = (UserDict, DictMixin, dict)
 _mutable_sequence_types = (UserList, list)
 
+# if sets is still available, register the mutable set from there as well
+try:
+    from sets import Set
+    _mutable_set_types += (Set,)
+except ImportError:
+    pass
+
 #: register Python 2.6 abstract base classes
 try:
     from collections import MutableSet, MutableMapping, MutableSequence