Returns a memory :class:`Patch` for the given *item* that shall be
        patched in the `data source`.

        :param item: item to patch.
        :param byte_order: encoding :class:`Byteorder` for the item.
        :type byte_order: :class:`Byteorder`, :class:`str`

def patch(self, item, byte_order=BYTEORDER):
        """ Returns a memory :class:`Patch` for the given *item* that shall be
        patched in the `data source`.

        :param item: item to patch.
        :param byte_order: encoding :class:`Byteorder` for the item.
        :type byte_order: :class:`Byteorder`, :class:`str`
        """
        # Re-index the data object
        self.index_data()

        if is_container(item):
            length = item.container_size()
            if length[1] is not 0:
                # Incomplete container
                raise ContainerLengthError(item, length)

            field = item.first_field()
            if field is None:
                # Empty container?
                return None

            index = field.index
            if index.bit is not 0:
                # Bad placed container
                raise FieldIndexError(field, index)

            # Create a dummy byte array filled with zero bytes.
            # The dummy byte array is necessary because the length of
            # the buffer must correlate to the field indexes of the
            # appending fields.
            buffer = bytearray(b'\x00' * index.byte)

            # Append to the buffer the content mapped by the container fields
            item.serialize(buffer, index, byte_order=byte_order)

            # Content of the buffer mapped by the container fields
            content = buffer[index.byte:]

            if len(content) != length[0]:
                # Not correct filled buffer!
                raise BufferError(len(content), length[0])

            return Patch(content,
                         index.address,
                         byte_order,
                         length[0] * 8,
                         0,
                         False)
        elif is_field(item):
            # Field index
            index = item.index
            # Field alignment
            alignment = item.alignment

            if index.bit != alignment.bit_offset:
                # Bad aligned field?
                raise FieldGroupOffsetError(
                    item, index, Alignment(alignment.byte_size, index.bit))

            # Create a dummy byte array filled with zero bytes.
            # The dummy byte array is necessary because the length of
            # the buffer must correlate to the field index of the
            # appending field group.
            buffer = bytearray(b'\x00' * index.byte)

            # Append to the buffer the content mapped by the field
            item.serialize(buffer, index, byte_order=byte_order)

            # Content of the buffer mapped by the field group
            content = buffer[index.byte:]

            if len(content) != alignment.byte_size:
                # Not correct filled buffer!
                raise BufferError(len(content), alignment.byte_size)

            # Patch size in bytes for the field in the content buffer
            patch_size, bit_offset = divmod(item.bit_size, 8)
            if bit_offset is not 0:
                inject = True
                patch_size += 1
            else:
                inject = False

            # Patch offset in bytes for the field in the content buffer
            patch_offset, bit_offset = divmod(alignment.bit_offset, 8)
            if bit_offset is not 0:
                inject = True

            if byte_order is Byteorder.big:
                start = alignment.byte_size - (patch_offset + patch_size)
                stop = alignment.byte_size - patch_offset
            else:
                start = patch_offset
                stop = patch_offset + patch_size

            return Patch(content[start:stop],
                         index.address + start,
                         byte_order,
                         item.bit_size,
                         bit_offset,
                         inject)
        else:
            raise MemberTypeError(self, item)