docs: def decodepackbits(encoded):
      """Decompress PackBits encoded byte string.
  
      PackBits is a simple byte-oriented run-length compression scheme.
  
      """
      func = ord if sys.version[0] == '2' else lambda x: x
      result = []
      i = 0
      try:
          while True:
              n = func(encoded[i]) + 1
              i += 1
              if n < 129:
                  result.extend(encoded[i:i+n])
                  i += n
              elif n > 129:
                  result.extend(encoded[i:i+1] * (258-n))
                  i += 1
      except IndexError:
          pass
      return b''.join(result) if sys.version[0] == '2' else bytes(result)