Use apply_edit for both python2 and python3

This allows us to use the same name-checking when undoing and
redoing.