<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def edit_block(object):
 """ Handles edit blocks undo states. :param object: Object to decorate. :type object: object :return: Object. :rtype: object """


    @functools.wraps(object)
    def edit_block_wrapper(*args, **kwargs):
        """
        Handles edit blocks undo states.

        :param \*args: Arguments.
        :type \*args: \*
        :param \*\*kwargs: Keywords arguments.
        :type \*\*kwargs: \*\*
        :return: Object.
        :rtype: object
        """

        if args:
            cursor = foundations.common.get_first_item(args).textCursor()
            cursor.beginEditBlock()
        value = None
        try:
            value = object(*args, **kwargs)
        finally:
            if args:
                cursor.endEditBlock()
            return value

    return edit_block_wrapper