# Buggy code
def _is_packed_binary(self, data):
    """
    Check if data is hexadecimal packed

    :param data:
    :return:
    """
    packed = False
    if len(data) == 16 and ":" not in data:
        try:
            packed = bool(int(str(bytearray(data)).encode("hex"), 16))
        except ValueError:
            pass

    return packed


# Traceback (TypeError)
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
TypeError: unicode argument without an encoding
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 410, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 47, in run
caller = salt.cli.caller.Caller.factory(self.config)
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 79, in factory
return ZeroMQCaller(opts, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 291, in __init__
super(ZeroMQCaller, self).__init__(opts)
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 102, in __init__
self.minion = salt.minion.SMinion(opts)
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 806, in __init__
lambda: self.eval_master(self.opts, failed=True)
File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 457, in run_sync
return future_cell[0].result()
File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result
raise_exc_info(self._exc_info)
File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 285, in wrapper
yielded = next(result)
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 694, in eval_master
opts.update(prep_ip_port(opts))
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 265, in prep_ip_port
host, port = parse_host_port(opts['master'])
File "/usr/lib/python2.7/dist-packages/salt/utils/network.py", line 1956, in parse_host_port
host_ip = ipaddress.ip_address(host).compressed
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
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 410, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 47, in run
caller = salt.cli.caller.Caller.factory(self.config)
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 79, in factory
return ZeroMQCaller(opts, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 291, in __init__
super(ZeroMQCaller, self).__init__(opts)
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 102, in __init__
self.minion = salt.minion.SMinion(opts)
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 806, in __init__
lambda: self.eval_master(self.opts, failed=True)
File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 457, in run_sync
return future_cell[0].result()
File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result
raise_exc_info(self._exc_info)
File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 285, in wrapper
yielded = next(result)
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 694, in eval_master
opts.update(prep_ip_port(opts))
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 265, in prep_ip_port
host, port = parse_host_port(opts['master'])
File "/usr/lib/python2.7/dist-packages/salt/utils/network.py", line 1956, in parse_host_port
host_ip = ipaddress.ip_address(host).compressed
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 _is_packed_binary(self, data):
    """
    Check if data is hexadecimal packed

    :param data:
    :return:
    """
    packed = False
    if isinstance(data, bytes) and len(data) == 16 and b":" not in data:
        try:
            packed = bool(int(str(bytearray(data)).encode("hex"), 16))
        except ValueError:
            pass

    return packed