<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register(self, func, *args, **kwargs):
 """ Record an undo operation. Also clears the redo stack. Raises IndexError when no group is open. """

        self._open[-1].append(UndoOperation(func, *args, **kwargs))
        if not (self._undoing or self._redoing):
            self._redo = []
        self.notify()