Glutton for Punishment

What does the expression “glutton for punishment” mean?

Definition: a person who repeatedly pursues a course of action that leads to difficulties or emotional pain

Example: So, he went back to Courtney even though she cheated on him three times? I guess he’s just a glutton for punishment.