As Pope John Paul II taught in the Catechism of the Catholic Church (CCC) 2267:
Assuming that the guilty party’s identity and responsibility have been fully determined, the traditional teaching of the Church does not exclude recourse to the death penalty, if this is the only possible way of effectively defending human lives against the unjust aggressor. . . .
Today, in fact, as a consequence of the possibilities which the state has for effectively preventing crime, by rendering one who has committed an offense incapable of doing harm – without definitely taking away from him the possibility of redeeming himself – the cases in which the execution of the offender is an absolute necessity “are very rare, if not practically nonexistent” (emphasis added; footnote omitted)
In his 2018 modification of CCC 2267, Pope Francis teaches:
Lastly, more effective systems of detention have been developed, which ensure the due protection of citizens but, at the same time, do not definitively deprive the guilty of the possibility of redemption. . . .
. . . [T]he Church teaches, in the light of the Gospel, that “the death penalty is inadmissible because it is an attack on the inviolability and dignity of the person,” and she works with determination for its abolition worldwide (emphasis added).
In making his modification, and in reading his change “in continuity with” the Church’s longstanding Tradition on the death penalty, as an accompanying document by the Congregation for the Doctrine of the Faith (CDF) conveys needs to be done, we can see that the Pope’s change regards not a modification of the Church’s fundamental and definitive teaching, which a Pope cannot change, but rather its social or disciplinary application.
In that light, one exception would be in a poor country in which “more effective systems of detention have [not] been developed, [and thus] which [cannot] ensure the due protection of citizens. . . .”