code: def _writeblock(cls, block, is_last=False):
          
  
          data = bytearray()
          code = (block.code | 128) if is_last else block.code
          datum = block.write()
          size = len(datum)
          if size > cls._MAX_SIZE:
              if block._distrust_size and block._invalid_overflow_size != -1:
                  # The original size of this block was (1) wrong and (2)
                  # the real size doesn't allow us to save the file
                  # according to the spec (too big for 24 bit uint). Instead
                  # simply write back the original wrong size.. at least
                  # we don't make the file more "broken" as it is.
                  size = block._invalid_overflow_size
              else:
                  raise error("block is too long to write")
          assert not size > cls._MAX_SIZE
          length = struct.pack(">I", size)[-3:]
          data.append(code)
          data += length
          data += datum
          return data
docs: Returns the block content + header.
  
          Raises error.