docs: def _unpack(formatstring, packed):
      """Unpack a bytestring into a value.
  
      Uses the built-in :mod:`struct` Python module.
  
      Args:
          * formatstring (str): String for the packing. See the :mod:`struct` module for details.
          * packed (str): The bytestring to be unpacked.
  
      Returns:
          A value. The type depends on the formatstring.
  
      Raises:
          ValueError
  
      Note that the :mod:`struct` module wants byte buffers for Python3,
      but bytestrings for Python2. This is compensated for automatically.
  
      """
      _checkString(formatstring, description='formatstring', minlength=1)
      _checkString(packed, description='packed string', minlength=1)
  
      if sys.version_info[0] > 2:
          packed = bytes(packed, encoding='latin1')  # Convert types to make it Python3 compatible
  
      try:
          value = struct.unpack(formatstring, packed)[0]
      except:
          errortext = 'The received bytestring is probably wrong, as the bytestring-to-num conversion failed.'
          errortext += ' Bytestring: {0!r} Struct format code is: {1}'
          raise ValueError(errortext.format(packed, formatstring))
  
      return value