Caught in a tangle on the Death Penalty & Exsurge Domine. Can someone help?

Preface this by stating I'm a devoted lifelong Catholic who just wants to assent to the Church as best he can.

CCC 2267 - most people tend to focus on the 'effective systems of detention' part. However, it's the rest that troubles me. How can our growing understanding of the dignity of the person lead us to contradict God's own past commandments? Are we supposed to believe that God Himself has also developed a greater understanding? Of course not, that's ludicrous.

Most people also solely discuss the use of the death penalty as permissible in the absence of other methods of incarceration. However, for a great deal of Church history - particularly during the Counter-Reformation - the death penalty was utilised for another reason: the administration of justice for a particularly grievous offence; that is, as punishment for its own sake, rather than for future safety concerns.

In the papal bull Exsurge Domine, Pope Leo X proclaims that the burning of heretics at the stake is not contrary to the Will of the Spirit - that is to say, the Will of God. During the Counter-Reformation there were several vast prisons in England which were more than capable of housing a criminal for their natural lifespan, from the Tower to Marshalsea. Here, however, we have a Pope implicitly approving burning in certain circumstances. St Thomas More likewise spent his final moments assuring his executioner of the necessity of his office (after having himself spent years imprisoned).

Also, unlike some, I'm not going to have an instinctive emotional response and say that Pope Leo X was wrong. Pain and humiliation inflicted as punishment are not intrinsically evil, especially at a time when the Church faced an existential threat.

But how are we to square the permissible burning of heretics with Francis' comments about 'the inviolability and dignity of the person'? How can one intellectually assent to Leo's papal bull back in the 16th century, and now intellectually assent to Francis' revisionism, without a fundamental and irrevocable contradiction? How can the Church itself now be campaigning to eliminate the death penalty internationally?

I say all this as someone against the death penalty in most circumstances. However, every discussion I've seen around this devolves into arguments for and against the death penalty, and so misses the bigger problem: the theological contradiction. So what am I to make of it?