From: Armin Ronacher Date: Thu, 19 Feb 2009 18:57:01 +0000 (+0100) Subject: jinja2.sandbox should not warn on 2.6 any more. X-Git-Tag: 2.2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51097174e9bcc300df323c959ceffdc335fdaf6a;p=thirdparty%2Fjinja.git jinja2.sandbox should not warn on 2.6 any more. --HG-- branch : trunk --- diff --git a/jinja2/sandbox.py b/jinja2/sandbox.py index c29bdea2..f93219b2 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