code: def _hexdecode(hexstring):
      
      # Note: For Python3 the appropriate would be: raise TypeError(new_error_message) from err
      # but the Python2 interpreter will indicate SyntaxError.
      # Thus we need to live with this warning in Python3:
      # 'During handling of the above exception, another exception occurred'
  
      _checkString(hexstring, description='hexstring')
  
      if len(hexstring) % 2 != 0:
          raise ValueError('The input hexstring must be of even length. Given: {!r}'.format(hexstring))
  
      if sys.version_info[0] > 2:
          by = bytes(hexstring, 'latin1')
          try:
              return str(binascii.unhexlify(by), encoding='latin1')
          except binascii.Error as err:
              new_error_message = 'Hexdecode reported an error: {!s}. Input hexstring: {}'.format(err.args[0], hexstring)
              raise TypeError(new_error_message)
  
      else:
          try:
              return hexstring.decode('hex')
          except TypeError as err:
              raise TypeError('Hexdecode reported an error: {}. Input hexstring: {}'.format(err.message, hexstring))
docs: Convert a hex encoded string to a byte string.
  
      For example '4A' will return 'J', and '04' will return ``'\\x04'`` (which has length 1).
  
      Args:
          hexstring (str): Can be for example 'A3' or 'A3B4'. Must be of even length.
          Allowed characters are '0' to '9', 'a' to 'f' and 'A' to 'F' (not space).
  
      Returns:
          A string of half the length, with characters corresponding to all 0-255 values for each byte.
  
      Raises:
          TypeError, ValueError