diff options
author | Adam J. Stewart <ajstewart426@gmail.com> | 2021-02-01 11:30:25 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-01 11:30:25 -0600 |
commit | 40a40e0265d6704a7836aeb30a776d66da8f7fe6 (patch) | |
tree | bd4f91f912989bf0145615529aa25641c8a1ce68 /lib/spack/external/jinja2 | |
parent | f78140361551401de2c7a46c29440a0136d80f23 (diff) | |
download | spack-40a40e0265d6704a7836aeb30a776d66da8f7fe6.tar.gz spack-40a40e0265d6704a7836aeb30a776d66da8f7fe6.tar.bz2 spack-40a40e0265d6704a7836aeb30a776d66da8f7fe6.tar.xz spack-40a40e0265d6704a7836aeb30a776d66da8f7fe6.zip |
Python 3.10 support: collections.abc (#20441)
Diffstat (limited to 'lib/spack/external/jinja2')
-rw-r--r-- | lib/spack/external/jinja2/runtime.py | 8 | ||||
-rw-r--r-- | lib/spack/external/jinja2/sandbox.py | 12 | ||||
-rw-r--r-- | lib/spack/external/jinja2/tests.py | 7 | ||||
-rw-r--r-- | lib/spack/external/jinja2/utils.py | 8 |
4 files changed, 28 insertions, 7 deletions
diff --git a/lib/spack/external/jinja2/runtime.py b/lib/spack/external/jinja2/runtime.py index f9d7a6806c..52dfeaebd6 100644 --- a/lib/spack/external/jinja2/runtime.py +++ b/lib/spack/external/jinja2/runtime.py @@ -315,10 +315,14 @@ class Context(with_metaclass(ContextMeta)): # register the context as mapping if possible try: - from collections import Mapping + from collections.abc import Mapping Mapping.register(Context) except ImportError: - pass + try: + from collections import Mapping + Mapping.register(Context) + except ImportError: + pass class BlockReference(object): diff --git a/lib/spack/external/jinja2/sandbox.py b/lib/spack/external/jinja2/sandbox.py index 93fb9d45f3..b9e5ec495a 100644 --- a/lib/spack/external/jinja2/sandbox.py +++ b/lib/spack/external/jinja2/sandbox.py @@ -14,7 +14,7 @@ """ import types import operator -from collections import Mapping +import sys from jinja2.environment import Environment from jinja2.exceptions import SecurityError from jinja2._compat import string_types, PY2 @@ -23,6 +23,11 @@ from jinja2.utils import Markup from markupsafe import EscapeFormatter from string import Formatter +if sys.version_info >= (3, 3): + from collections.abc import Mapping +else: + from collections import Mapping + #: maximum number of items a range may produce MAX_RANGE = 100000 @@ -79,7 +84,10 @@ except ImportError: pass #: register Python 2.6 abstract base classes -from collections import MutableSet, MutableMapping, MutableSequence +if sys.version_info >= (3, 3): + from collections.abc import MutableSet, MutableMapping, MutableSequence +else: + from collections import MutableSet, MutableMapping, MutableSequence _mutable_set_types += (MutableSet,) _mutable_mapping_types += (MutableMapping,) _mutable_sequence_types += (MutableSequence,) diff --git a/lib/spack/external/jinja2/tests.py b/lib/spack/external/jinja2/tests.py index 0adc3d4dbc..d5d6b5b33f 100644 --- a/lib/spack/external/jinja2/tests.py +++ b/lib/spack/external/jinja2/tests.py @@ -10,11 +10,16 @@ """ import operator import re -from collections import Mapping +import sys from jinja2.runtime import Undefined from jinja2._compat import text_type, string_types, integer_types import decimal +if sys.version_info >= (3, 3): + from collections.abc import Mapping +else: + from collections import Mapping + number_re = re.compile(r'^-?\d+(\.\d+)?$') regex_type = type(number_re) diff --git a/lib/spack/external/jinja2/utils.py b/lib/spack/external/jinja2/utils.py index 502a311c08..cff4e783a8 100644 --- a/lib/spack/external/jinja2/utils.py +++ b/lib/spack/external/jinja2/utils.py @@ -482,10 +482,14 @@ class LRUCache(object): # register the LRU cache as mutable mapping if possible try: - from collections import MutableMapping + from collections.abc import MutableMapping MutableMapping.register(LRUCache) except ImportError: - pass + try: + from collections import MutableMapping + MutableMapping.register(LRUCache) + except ImportError: + pass def select_autoescape(enabled_extensions=('html', 'htm', 'xml'), |