Update six to v1.16.0 (#27265)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							97ebcb99b4
						
					
				
				
					commit
					12da0a9a69
				
			
							
								
								
									
										2
									
								
								lib/spack/external/__init__.py
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								lib/spack/external/__init__.py
									
									
									
									
										vendored
									
									
								
							@@ -103,7 +103,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
* Homepage: https://pypi.python.org/pypi/six
 | 
					* Homepage: https://pypi.python.org/pypi/six
 | 
				
			||||||
* Usage: Python 2 and 3 compatibility utilities.
 | 
					* Usage: Python 2 and 3 compatibility utilities.
 | 
				
			||||||
* Version: 1.11.0
 | 
					* Version: 1.16.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
macholib
 | 
					macholib
 | 
				
			||||||
--------
 | 
					--------
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										147
									
								
								lib/spack/external/six.py
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										147
									
								
								lib/spack/external/six.py
									
									
									
									
										vendored
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
# Copyright (c) 2010-2017 Benjamin Peterson
 | 
					# Copyright (c) 2010-2020 Benjamin Peterson
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
					# Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
				
			||||||
# of this software and associated documentation files (the "Software"), to deal
 | 
					# of this software and associated documentation files (the "Software"), to deal
 | 
				
			||||||
@@ -29,7 +29,7 @@
 | 
				
			|||||||
import types
 | 
					import types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__author__ = "Benjamin Peterson <benjamin@python.org>"
 | 
					__author__ = "Benjamin Peterson <benjamin@python.org>"
 | 
				
			||||||
__version__ = "1.11.0"
 | 
					__version__ = "1.16.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Useful for very coarse version differentiation.
 | 
					# Useful for very coarse version differentiation.
 | 
				
			||||||
@@ -71,6 +71,11 @@ def __len__(self):
 | 
				
			|||||||
            MAXSIZE = int((1 << 63) - 1)
 | 
					            MAXSIZE = int((1 << 63) - 1)
 | 
				
			||||||
        del X
 | 
					        del X
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if PY34:
 | 
				
			||||||
 | 
					    from importlib.util import spec_from_loader
 | 
				
			||||||
 | 
					else:
 | 
				
			||||||
 | 
					    spec_from_loader = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def _add_doc(func, doc):
 | 
					def _add_doc(func, doc):
 | 
				
			||||||
    """Add documentation to a function."""
 | 
					    """Add documentation to a function."""
 | 
				
			||||||
@@ -186,6 +191,11 @@ def find_module(self, fullname, path=None):
 | 
				
			|||||||
            return self
 | 
					            return self
 | 
				
			||||||
        return None
 | 
					        return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def find_spec(self, fullname, path, target=None):
 | 
				
			||||||
 | 
					        if fullname in self.known_modules:
 | 
				
			||||||
 | 
					            return spec_from_loader(fullname, self)
 | 
				
			||||||
 | 
					        return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __get_module(self, fullname):
 | 
					    def __get_module(self, fullname):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            return self.known_modules[fullname]
 | 
					            return self.known_modules[fullname]
 | 
				
			||||||
@@ -223,6 +233,12 @@ def get_code(self, fullname):
 | 
				
			|||||||
        return None
 | 
					        return None
 | 
				
			||||||
    get_source = get_code  # same as get_code
 | 
					    get_source = get_code  # same as get_code
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def create_module(self, spec):
 | 
				
			||||||
 | 
					        return self.load_module(spec.name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def exec_module(self, module):
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
_importer = _SixMetaPathImporter(__name__)
 | 
					_importer = _SixMetaPathImporter(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -255,9 +271,11 @@ class _MovedItems(_LazyModule):
 | 
				
			|||||||
    MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
 | 
					    MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
 | 
				
			||||||
    MovedModule("builtins", "__builtin__"),
 | 
					    MovedModule("builtins", "__builtin__"),
 | 
				
			||||||
    MovedModule("configparser", "ConfigParser"),
 | 
					    MovedModule("configparser", "ConfigParser"),
 | 
				
			||||||
 | 
					    MovedModule("collections_abc", "collections", "collections.abc" if sys.version_info >= (3, 3) else "collections"),
 | 
				
			||||||
    MovedModule("copyreg", "copy_reg"),
 | 
					    MovedModule("copyreg", "copy_reg"),
 | 
				
			||||||
    MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
 | 
					    MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
 | 
				
			||||||
    MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"),
 | 
					    MovedModule("dbm_ndbm", "dbm", "dbm.ndbm"),
 | 
				
			||||||
 | 
					    MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread" if sys.version_info < (3, 9) else "_thread"),
 | 
				
			||||||
    MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
 | 
					    MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
 | 
				
			||||||
    MovedModule("http_cookies", "Cookie", "http.cookies"),
 | 
					    MovedModule("http_cookies", "Cookie", "http.cookies"),
 | 
				
			||||||
    MovedModule("html_entities", "htmlentitydefs", "html.entities"),
 | 
					    MovedModule("html_entities", "htmlentitydefs", "html.entities"),
 | 
				
			||||||
@@ -637,13 +655,16 @@ def u(s):
 | 
				
			|||||||
    import io
 | 
					    import io
 | 
				
			||||||
    StringIO = io.StringIO
 | 
					    StringIO = io.StringIO
 | 
				
			||||||
    BytesIO = io.BytesIO
 | 
					    BytesIO = io.BytesIO
 | 
				
			||||||
 | 
					    del io
 | 
				
			||||||
    _assertCountEqual = "assertCountEqual"
 | 
					    _assertCountEqual = "assertCountEqual"
 | 
				
			||||||
    if sys.version_info[1] <= 1:
 | 
					    if sys.version_info[1] <= 1:
 | 
				
			||||||
        _assertRaisesRegex = "assertRaisesRegexp"
 | 
					        _assertRaisesRegex = "assertRaisesRegexp"
 | 
				
			||||||
        _assertRegex = "assertRegexpMatches"
 | 
					        _assertRegex = "assertRegexpMatches"
 | 
				
			||||||
 | 
					        _assertNotRegex = "assertNotRegexpMatches"
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        _assertRaisesRegex = "assertRaisesRegex"
 | 
					        _assertRaisesRegex = "assertRaisesRegex"
 | 
				
			||||||
        _assertRegex = "assertRegex"
 | 
					        _assertRegex = "assertRegex"
 | 
				
			||||||
 | 
					        _assertNotRegex = "assertNotRegex"
 | 
				
			||||||
else:
 | 
					else:
 | 
				
			||||||
    def b(s):
 | 
					    def b(s):
 | 
				
			||||||
        return s
 | 
					        return s
 | 
				
			||||||
@@ -665,6 +686,7 @@ def indexbytes(buf, i):
 | 
				
			|||||||
    _assertCountEqual = "assertItemsEqual"
 | 
					    _assertCountEqual = "assertItemsEqual"
 | 
				
			||||||
    _assertRaisesRegex = "assertRaisesRegexp"
 | 
					    _assertRaisesRegex = "assertRaisesRegexp"
 | 
				
			||||||
    _assertRegex = "assertRegexpMatches"
 | 
					    _assertRegex = "assertRegexpMatches"
 | 
				
			||||||
 | 
					    _assertNotRegex = "assertNotRegexpMatches"
 | 
				
			||||||
_add_doc(b, """Byte literal""")
 | 
					_add_doc(b, """Byte literal""")
 | 
				
			||||||
_add_doc(u, """Text literal""")
 | 
					_add_doc(u, """Text literal""")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -681,6 +703,10 @@ def assertRegex(self, *args, **kwargs):
 | 
				
			|||||||
    return getattr(self, _assertRegex)(*args, **kwargs)
 | 
					    return getattr(self, _assertRegex)(*args, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def assertNotRegex(self, *args, **kwargs):
 | 
				
			||||||
 | 
					    return getattr(self, _assertNotRegex)(*args, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if PY3:
 | 
					if PY3:
 | 
				
			||||||
    exec_ = getattr(moves.builtins, "exec")
 | 
					    exec_ = getattr(moves.builtins, "exec")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -716,16 +742,7 @@ def exec_(_code_, _globs_=None, _locs_=None):
 | 
				
			|||||||
""")
 | 
					""")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if sys.version_info[:2] == (3, 2):
 | 
					if sys.version_info[:2] > (3,):
 | 
				
			||||||
    exec_("""def raise_from(value, from_value):
 | 
					 | 
				
			||||||
    try:
 | 
					 | 
				
			||||||
        if from_value is None:
 | 
					 | 
				
			||||||
            raise value
 | 
					 | 
				
			||||||
        raise value from from_value
 | 
					 | 
				
			||||||
    finally:
 | 
					 | 
				
			||||||
        value = None
 | 
					 | 
				
			||||||
""")
 | 
					 | 
				
			||||||
elif sys.version_info[:2] > (3, 2):
 | 
					 | 
				
			||||||
    exec_("""def raise_from(value, from_value):
 | 
					    exec_("""def raise_from(value, from_value):
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        raise value from from_value
 | 
					        raise value from from_value
 | 
				
			||||||
@@ -805,13 +822,33 @@ def print_(*args, **kwargs):
 | 
				
			|||||||
_add_doc(reraise, """Reraise an exception.""")
 | 
					_add_doc(reraise, """Reraise an exception.""")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if sys.version_info[0:2] < (3, 4):
 | 
					if sys.version_info[0:2] < (3, 4):
 | 
				
			||||||
 | 
					    # This does exactly the same what the :func:`py3:functools.update_wrapper`
 | 
				
			||||||
 | 
					    # function does on Python versions after 3.2. It sets the ``__wrapped__``
 | 
				
			||||||
 | 
					    # attribute on ``wrapper`` object and it doesn't raise an error if any of
 | 
				
			||||||
 | 
					    # the attributes mentioned in ``assigned`` and ``updated`` are missing on
 | 
				
			||||||
 | 
					    # ``wrapped`` object.
 | 
				
			||||||
 | 
					    def _update_wrapper(wrapper, wrapped,
 | 
				
			||||||
 | 
					                        assigned=functools.WRAPPER_ASSIGNMENTS,
 | 
				
			||||||
 | 
					                        updated=functools.WRAPPER_UPDATES):
 | 
				
			||||||
 | 
					        for attr in assigned:
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                value = getattr(wrapped, attr)
 | 
				
			||||||
 | 
					            except AttributeError:
 | 
				
			||||||
 | 
					                continue
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                setattr(wrapper, attr, value)
 | 
				
			||||||
 | 
					        for attr in updated:
 | 
				
			||||||
 | 
					            getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
 | 
				
			||||||
 | 
					        wrapper.__wrapped__ = wrapped
 | 
				
			||||||
 | 
					        return wrapper
 | 
				
			||||||
 | 
					    _update_wrapper.__doc__ = functools.update_wrapper.__doc__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
 | 
					    def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
 | 
				
			||||||
              updated=functools.WRAPPER_UPDATES):
 | 
					              updated=functools.WRAPPER_UPDATES):
 | 
				
			||||||
        def wrapper(f):
 | 
					        return functools.partial(_update_wrapper, wrapped=wrapped,
 | 
				
			||||||
            f = functools.wraps(wrapped, assigned, updated)(f)
 | 
					                                 assigned=assigned, updated=updated)
 | 
				
			||||||
            f.__wrapped__ = wrapped
 | 
					    wraps.__doc__ = functools.wraps.__doc__
 | 
				
			||||||
            return f
 | 
					
 | 
				
			||||||
        return wrapper
 | 
					 | 
				
			||||||
else:
 | 
					else:
 | 
				
			||||||
    wraps = functools.wraps
 | 
					    wraps = functools.wraps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -824,7 +861,15 @@ def with_metaclass(meta, *bases):
 | 
				
			|||||||
    class metaclass(type):
 | 
					    class metaclass(type):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def __new__(cls, name, this_bases, d):
 | 
					        def __new__(cls, name, this_bases, d):
 | 
				
			||||||
            return meta(name, bases, d)
 | 
					            if sys.version_info[:2] >= (3, 7):
 | 
				
			||||||
 | 
					                # This version introduced PEP 560 that requires a bit
 | 
				
			||||||
 | 
					                # of extra care (we mimic what is done by __build_class__).
 | 
				
			||||||
 | 
					                resolved_bases = types.resolve_bases(bases)
 | 
				
			||||||
 | 
					                if resolved_bases is not bases:
 | 
				
			||||||
 | 
					                    d['__orig_bases__'] = bases
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                resolved_bases = bases
 | 
				
			||||||
 | 
					            return meta(name, resolved_bases, d)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @classmethod
 | 
					        @classmethod
 | 
				
			||||||
        def __prepare__(cls, name, this_bases):
 | 
					        def __prepare__(cls, name, this_bases):
 | 
				
			||||||
@@ -844,13 +889,75 @@ def wrapper(cls):
 | 
				
			|||||||
                orig_vars.pop(slots_var)
 | 
					                orig_vars.pop(slots_var)
 | 
				
			||||||
        orig_vars.pop('__dict__', None)
 | 
					        orig_vars.pop('__dict__', None)
 | 
				
			||||||
        orig_vars.pop('__weakref__', None)
 | 
					        orig_vars.pop('__weakref__', None)
 | 
				
			||||||
 | 
					        if hasattr(cls, '__qualname__'):
 | 
				
			||||||
 | 
					            orig_vars['__qualname__'] = cls.__qualname__
 | 
				
			||||||
        return metaclass(cls.__name__, cls.__bases__, orig_vars)
 | 
					        return metaclass(cls.__name__, cls.__bases__, orig_vars)
 | 
				
			||||||
    return wrapper
 | 
					    return wrapper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def ensure_binary(s, encoding='utf-8', errors='strict'):
 | 
				
			||||||
 | 
					    """Coerce **s** to six.binary_type.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    For Python 2:
 | 
				
			||||||
 | 
					      - `unicode` -> encoded to `str`
 | 
				
			||||||
 | 
					      - `str` -> `str`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    For Python 3:
 | 
				
			||||||
 | 
					      - `str` -> encoded to `bytes`
 | 
				
			||||||
 | 
					      - `bytes` -> `bytes`
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    if isinstance(s, binary_type):
 | 
				
			||||||
 | 
					        return s
 | 
				
			||||||
 | 
					    if isinstance(s, text_type):
 | 
				
			||||||
 | 
					        return s.encode(encoding, errors)
 | 
				
			||||||
 | 
					    raise TypeError("not expecting type '%s'" % type(s))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def ensure_str(s, encoding='utf-8', errors='strict'):
 | 
				
			||||||
 | 
					    """Coerce *s* to `str`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    For Python 2:
 | 
				
			||||||
 | 
					      - `unicode` -> encoded to `str`
 | 
				
			||||||
 | 
					      - `str` -> `str`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    For Python 3:
 | 
				
			||||||
 | 
					      - `str` -> `str`
 | 
				
			||||||
 | 
					      - `bytes` -> decoded to `str`
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    # Optimization: Fast return for the common case.
 | 
				
			||||||
 | 
					    if type(s) is str:
 | 
				
			||||||
 | 
					        return s
 | 
				
			||||||
 | 
					    if PY2 and isinstance(s, text_type):
 | 
				
			||||||
 | 
					        return s.encode(encoding, errors)
 | 
				
			||||||
 | 
					    elif PY3 and isinstance(s, binary_type):
 | 
				
			||||||
 | 
					        return s.decode(encoding, errors)
 | 
				
			||||||
 | 
					    elif not isinstance(s, (text_type, binary_type)):
 | 
				
			||||||
 | 
					        raise TypeError("not expecting type '%s'" % type(s))
 | 
				
			||||||
 | 
					    return s
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def ensure_text(s, encoding='utf-8', errors='strict'):
 | 
				
			||||||
 | 
					    """Coerce *s* to six.text_type.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    For Python 2:
 | 
				
			||||||
 | 
					      - `unicode` -> `unicode`
 | 
				
			||||||
 | 
					      - `str` -> `unicode`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    For Python 3:
 | 
				
			||||||
 | 
					      - `str` -> `str`
 | 
				
			||||||
 | 
					      - `bytes` -> decoded to `str`
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    if isinstance(s, binary_type):
 | 
				
			||||||
 | 
					        return s.decode(encoding, errors)
 | 
				
			||||||
 | 
					    elif isinstance(s, text_type):
 | 
				
			||||||
 | 
					        return s
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        raise TypeError("not expecting type '%s'" % type(s))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def python_2_unicode_compatible(klass):
 | 
					def python_2_unicode_compatible(klass):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    A decorator that defines __unicode__ and __str__ methods under Python 2.
 | 
					    A class decorator that defines __unicode__ and __str__ methods under Python 2.
 | 
				
			||||||
    Under Python 3 it does nothing.
 | 
					    Under Python 3 it does nothing.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    To support Python 2 and 3 with a single code base, define a __str__ method
 | 
					    To support Python 2 and 3 with a single code base, define a __str__ method
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user