# Buggy code
def __init__(self, address):
    """
    Instantiate a new IPv6 address object. Scope is moved to an attribute 'scope'.

    Args:
        address: A string or integer representing the IP

          Additionally, an integer can be passed, so
          IPv6Address('2001:db8::') == IPv6Address(42540766411282592856903984951653826560)
          or, more generally
          IPv6Address(int(IPv6Address('2001:db8::'))) == IPv6Address('2001:db8::')

    Raises:
        AddressValueError: If address isn't a valid IPv6 address.

    :param address:
    """
    # pylint: disable-all
    if not hasattr(self, "_is_packed_binary"):
        # This method (below) won't be around for some Python 3 versions
        # and we need check this differently anyway
        self._is_packed_binary = lambda p: isinstance(p, bytes)
    # pylint: enable-all

    if isinstance(address, string_types) and "%" in address:
        buff = address.split("%")
        if len(buff) != 2:
            raise SaltException('Invalid IPv6 address: "{}"'.format(address))
        address, self.__scope = buff
    else:
        self.__scope = None

    if sys.version_info.major == 2:
        ipaddress._BaseAddress.__init__(self, address)
        ipaddress._BaseV6.__init__(self, address)
    else:
        # Python 3.4 fix. Versions higher are simply not affected
        # https://github.com/python/cpython/blob/3.4/Lib/ipaddress.py#L543-L544
        self._version = 6
        self._max_prefixlen = ipaddress.IPV6LENGTH

    # Efficient constructor from integer.
    if isinstance(address, integer_types):
        self._check_int_address(address)
        self._ip = address
    elif self._is_packed_binary(address):
        self._check_packed_address(address, 16)
        self._ip = ipaddress._int_from_bytes(address, "big")
    else:
        address = str(address)
        if "/" in address:
            raise ipaddress.AddressValueError("Unexpected '/' in {}".format(address))
        self._ip = self._ip_int_from_string(address)


# Traceback (TypeError)
2019-01-21 08:13:03,063 [salt.utils.process:772 ][ERROR   ][9447] An un-handled exception from the multiprocessing process 'Maintenance-4' was caught:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/utils/process.py", line 765, in _run
return self._original_run()
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 234, in run
salt.daemons.masterapi.clean_old_jobs(self.opts)
File "/usr/lib/python2.7/dist-packages/salt/daemons/masterapi.py", line 169, in clean_old_jobs
rend=False,
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 883, in __init__
role='master'
File "/usr/lib/python2.7/dist-packages/salt/config/__init__.py", line 2434, in minion_config
minion_id=minion_id)
File "/usr/lib/python2.7/dist-packages/salt/config/__init__.py", line 3772, in apply_minion_config
cache_minion_id=cache_minion_id)
File "/usr/lib/python2.7/dist-packages/salt/config/__init__.py", line 3669, in get_id
is_ipv4 = salt.utils.network.is_ipv4(newid)
File "/usr/lib/python2.7/dist-packages/salt/utils/network.py", line 260, in is_ipv4
return ipaddress.ip_address(ip).version == 4
File "/usr/lib/python2.7/dist-packages/salt/ext/ipaddress.py", line 115, in ip_address
return IPv6Address(address)
File "/usr/lib/python2.7/dist-packages/salt/_compat.py", line 175, in __init__
elif self._is_packed_binary(address):
File "/usr/lib/python2.7/dist-packages/salt/_compat.py", line 194, in _is_packed_binary
packed = bool(int(str(bytearray(data)).encode('hex'), 16))
TypeError: unicode argument without an encoding

# Fixed code
def __init__(self, address):
    """
    Instantiate a new IPv6 address object. Scope is moved to an attribute 'scope'.

    Args:
        address: A string or integer representing the IP

          Additionally, an integer can be passed, so
          IPv6Address('2001:db8::') == IPv6Address(42540766411282592856903984951653826560)
          or, more generally
          IPv6Address(int(IPv6Address('2001:db8::'))) == IPv6Address('2001:db8::')

    Raises:
        AddressValueError: If address isn't a valid IPv6 address.

    :param address:
    """
    if isinstance(address, string_types) and "%" in address:
        buff = address.split("%")
        if len(buff) != 2:
            raise SaltException('Invalid IPv6 address: "{}"'.format(address))
        address, self.__scope = buff
    else:
        self.__scope = None

    if sys.version_info.major == 2:
        ipaddress._BaseAddress.__init__(self, address)
        ipaddress._BaseV6.__init__(self, address)
    else:
        # Python 3.4 fix. Versions higher are simply not affected
        # https://github.com/python/cpython/blob/3.4/Lib/ipaddress.py#L543-L544
        self._version = 6
        self._max_prefixlen = ipaddress.IPV6LENGTH

    # Efficient constructor from integer.
    if isinstance(address, integer_types):
        self._check_int_address(address)
        self._ip = address
    elif self._is_packed_binary(address):
        self._check_packed_address(address, 16)
        self._ip = ipaddress._int_from_bytes(address, "big")
    else:
        address = str(address)
        if "/" in address:
            raise ipaddress.AddressValueError("Unexpected '/' in {}".format(address))
        self._ip = self._ip_int_from_string(address)