docs: def _read_bytes(fp, buf):
      """Read bytes from a file-like object
  
      @param fp: File-like object that implements read(int)
      @type fp: file
  
      @param buf: Buffer to read into
      @type buf: bytes
  
      @return: buf
      """
  
      # Do the first read without resizing the input buffer
      offset = 0
      remaining = len(buf)
      while remaining > 0:
          l = fp.readinto((ctypes.c_char * remaining).from_buffer(buf, offset))
          if l is None or l == 0:
              return offset
          offset += l
          remaining -= l
      return offset