I don't see how the words of Pope John XXII can be construed to mean self-flagellation:
But the faithful must also be encouraged to do outward acts of penance, both to keep their bodies under the strict control of reason and faith, and to make amends for their own and other people's sins.
"Outward acts of penance" does not necessarily mean beating yourself.
The catechism of the Catholic Church states: The way of perfection passes by way of the Cross. There is no holiness without renunciation and spiritual battle. Spiritual progress entails the ascesis and mortification that gradually lead to living in the peace and joy of the Beatitudes
The definition of "mortification" in Webster's Dictionary: "the control of physical desires and passions by self-denial, such as fasting."
Not exactly the same as whipping yourself - is it?
Pope Paul VI:
The necessity of mortification of the flesh stands clearly revealed if we consider the fragility of our nature, in which, since Adams sin, flesh and spirit have contrasting desires. This exercise of bodily mortification far removed from any form of stoicism does not imply a condemnation of the flesh which the Son of God deigned to assume. On the contrary, mortification aims at the 'liberation' of man.
Again - read the definition of "mortification" - it does NOT mean beating oneself.
I guess it all depends on how far one takes the concept of self-inflicted suffering. It seems there are zealots in all religions.