Python 3.10 support: collections.abc (#20441)
This commit is contained in:
7
lib/spack/external/_pytest/assertion/util.py
vendored
7
lib/spack/external/_pytest/assertion/util.py
vendored
@@ -5,9 +5,12 @@
|
||||
import _pytest._code
|
||||
import py
|
||||
try:
|
||||
from collections import Sequence
|
||||
from collections.abc import Sequence
|
||||
except ImportError:
|
||||
Sequence = list
|
||||
try:
|
||||
from collections import Sequence
|
||||
except ImportError:
|
||||
Sequence = list
|
||||
|
||||
|
||||
u = py.builtin._totext
|
||||
|
7
lib/spack/external/_pytest/main.py
vendored
7
lib/spack/external/_pytest/main.py
vendored
@@ -10,9 +10,12 @@
|
||||
import _pytest._code
|
||||
import py
|
||||
try:
|
||||
from collections import MutableMapping as MappingMixin
|
||||
from collections.abc import MutableMapping as MappingMixin
|
||||
except ImportError:
|
||||
from UserDict import DictMixin as MappingMixin
|
||||
try:
|
||||
from collections import MutableMapping as MappingMixin
|
||||
except ImportError:
|
||||
from UserDict import DictMixin as MappingMixin
|
||||
|
||||
from _pytest.config import directory_arg, UsageError, hookimpl
|
||||
from _pytest.outcomes import exit
|
||||
|
5
lib/spack/external/_pytest/python_api.py
vendored
5
lib/spack/external/_pytest/python_api.py
vendored
@@ -398,7 +398,10 @@ def approx(expected, rel=None, abs=None, nan_ok=False):
|
||||
__ https://docs.python.org/3/reference/datamodel.html#object.__ge__
|
||||
"""
|
||||
|
||||
from collections import Mapping, Sequence
|
||||
if sys.version_info >= (3, 3):
|
||||
from collections.abc import Mapping, Sequence
|
||||
else:
|
||||
from collections import Mapping, Sequence
|
||||
from _pytest.compat import STRING_TYPES as String
|
||||
|
||||
# Delegate the comparison to a class that knows how to deal with the type
|
||||
|
8
lib/spack/external/jinja2/runtime.py
vendored
8
lib/spack/external/jinja2/runtime.py
vendored
@@ -315,10 +315,14 @@ def __repr__(self):
|
||||
|
||||
# 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):
|
||||
|
12
lib/spack/external/jinja2/sandbox.py
vendored
12
lib/spack/external/jinja2/sandbox.py
vendored
@@ -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 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 @@
|
||||
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,)
|
||||
|
7
lib/spack/external/jinja2/tests.py
vendored
7
lib/spack/external/jinja2/tests.py
vendored
@@ -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)
|
||||
|
||||
|
8
lib/spack/external/jinja2/utils.py
vendored
8
lib/spack/external/jinja2/utils.py
vendored
@@ -482,10 +482,14 @@ def __reversed__(self):
|
||||
|
||||
# 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'),
|
||||
|
7
lib/spack/external/markupsafe/__init__.py
vendored
7
lib/spack/external/markupsafe/__init__.py
vendored
@@ -10,10 +10,15 @@
|
||||
"""
|
||||
import re
|
||||
import string
|
||||
from collections import Mapping
|
||||
import sys
|
||||
from markupsafe._compat import text_type, string_types, int_types, \
|
||||
unichr, iteritems, PY2
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
from collections.abc import Mapping
|
||||
else:
|
||||
from collections import Mapping
|
||||
|
||||
__version__ = "1.0"
|
||||
|
||||
__all__ = ['Markup', 'soft_unicode', 'escape', 'escape_silent']
|
||||
|
7
lib/spack/external/ruamel/yaml/comments.py
vendored
7
lib/spack/external/ruamel/yaml/comments.py
vendored
@@ -9,7 +9,12 @@
|
||||
a separate base
|
||||
"""
|
||||
|
||||
from collections import MutableSet
|
||||
import sys
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
from collections.abc import MutableSet
|
||||
else:
|
||||
from collections import MutableSet
|
||||
|
||||
__all__ = ["CommentedSeq", "CommentedMap", "CommentedOrderedMap",
|
||||
"CommentedSet", 'comment_attrib', 'merge_attrib']
|
||||
|
7
lib/spack/external/ruamel/yaml/compat.py
vendored
7
lib/spack/external/ruamel/yaml/compat.py
vendored
@@ -12,9 +12,12 @@
|
||||
from ruamel.ordereddict import ordereddict
|
||||
except:
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
from collections.abc import OrderedDict
|
||||
except ImportError:
|
||||
from ordereddict import OrderedDict
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from ordereddict import OrderedDict
|
||||
# to get the right name import ... as ordereddict doesn't do that
|
||||
|
||||
class ordereddict(OrderedDict):
|
||||
|
19
lib/spack/external/ruamel/yaml/constructor.py
vendored
19
lib/spack/external/ruamel/yaml/constructor.py
vendored
@@ -3,7 +3,6 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import base64
|
||||
import binascii
|
||||
@@ -26,6 +25,12 @@
|
||||
from ruamel.yaml.scalarstring import * # NOQA
|
||||
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
from collections.abc import Hashable
|
||||
else:
|
||||
from collections import Hashable
|
||||
|
||||
|
||||
__all__ = ['BaseConstructor', 'SafeConstructor', 'Constructor',
|
||||
'ConstructorError', 'RoundTripConstructor']
|
||||
|
||||
@@ -163,7 +168,7 @@ def construct_mapping(self, node, deep=False):
|
||||
# keys can be list -> deep
|
||||
key = self.construct_object(key_node, deep=True)
|
||||
# lists are not hashable, but tuples are
|
||||
if not isinstance(key, collections.Hashable):
|
||||
if not isinstance(key, Hashable):
|
||||
if isinstance(key, list):
|
||||
key = tuple(key)
|
||||
if PY2:
|
||||
@@ -175,7 +180,7 @@ def construct_mapping(self, node, deep=False):
|
||||
"found unacceptable key (%s)" %
|
||||
exc, key_node.start_mark)
|
||||
else:
|
||||
if not isinstance(key, collections.Hashable):
|
||||
if not isinstance(key, Hashable):
|
||||
raise ConstructorError(
|
||||
"while constructing a mapping", node.start_mark,
|
||||
"found unhashable key", key_node.start_mark)
|
||||
@@ -959,7 +964,7 @@ def construct_mapping(self, node, maptyp, deep=False):
|
||||
# keys can be list -> deep
|
||||
key = self.construct_object(key_node, deep=True)
|
||||
# lists are not hashable, but tuples are
|
||||
if not isinstance(key, collections.Hashable):
|
||||
if not isinstance(key, Hashable):
|
||||
if isinstance(key, list):
|
||||
key = tuple(key)
|
||||
if PY2:
|
||||
@@ -971,7 +976,7 @@ def construct_mapping(self, node, maptyp, deep=False):
|
||||
"found unacceptable key (%s)" %
|
||||
exc, key_node.start_mark)
|
||||
else:
|
||||
if not isinstance(key, collections.Hashable):
|
||||
if not isinstance(key, Hashable):
|
||||
raise ConstructorError(
|
||||
"while constructing a mapping", node.start_mark,
|
||||
"found unhashable key", key_node.start_mark)
|
||||
@@ -1003,7 +1008,7 @@ def construct_setting(self, node, typ, deep=False):
|
||||
# keys can be list -> deep
|
||||
key = self.construct_object(key_node, deep=True)
|
||||
# lists are not hashable, but tuples are
|
||||
if not isinstance(key, collections.Hashable):
|
||||
if not isinstance(key, Hashable):
|
||||
if isinstance(key, list):
|
||||
key = tuple(key)
|
||||
if PY2:
|
||||
@@ -1015,7 +1020,7 @@ def construct_setting(self, node, typ, deep=False):
|
||||
"found unacceptable key (%s)" %
|
||||
exc, key_node.start_mark)
|
||||
else:
|
||||
if not isinstance(key, collections.Hashable):
|
||||
if not isinstance(key, Hashable):
|
||||
raise ConstructorError(
|
||||
"while constructing a mapping", node.start_mark,
|
||||
"found unhashable key", key_node.start_mark)
|
||||
|
Reference in New Issue
Block a user