From 51097174e9bcc300df323c959ceffdc335fdaf6a Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 19 Feb 2009 19:57:01 +0100 Subject: [PATCH] jinja2.sandbox should not warn on 2.6 any more. --HG-- branch : trunk --- jinja2/sandbox.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/jinja2/sandbox.py b/jinja2/sandbox.py index c29bdea..f93219b 100644 --- a/jinja2/sandbox.py +++ b/jinja2/sandbox.py @@ -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 -- 2.26.2