Some actions incur automatic excommunication. While it is debated whether a Pope can lose the office via heresy, what happens if a pope commits a sin other than heresy, such as abortion or violating the seal of confession, which carries an equal penalty? Is the Pope subject to the automatic excommunication? If so, would the election of a new Pope be called for? What would then happen (in terms of the Papacy) if the excommunicated Pope repented and rejoined the church?
As the article here states (linked in the comments), the short answer is that the current legislation of the Church (i.e. the Canon Law) does not foresee such situation to occur. Perhaps it does not do so because under its own beliefs, God will never allow that to happen.
On the one hand, some excommunications (ferendae sententiae) are not automatic. They require a legal procedure in the form of a judicial investigation. One thing this investigation aims to find out is if all the conditions for an excommunication were met, e.g. that the person knew about the penalties of the sinful action to be conducted. These investigations are carried out by a judge, which is designated by the bishop. Canon Law states:
Can. 1419 §1. In each diocese and for all cases not expressly excepted by law, the judge of first instance is the diocesan bishop, who can exercise judicial power personally or through others according to the following canons.
The bishop has himself the right to be the judge, and to reserve some cases to himself:
Can. 1419 §2. The judicial vicar constitutes one tribunal with the bishop but cannot judge cases which the bishop reserves to himself.
Thus, ultimately it is the Pope, as Bishop of Rome, who can decide if he is to judge himself or not, as the matter cannot be delegated to a superior.
Now, recall that the purpose of excommunication is to make the person reconsider his/her error, and reconcile with God/Church. Thus, these types of excommunications could be quickly irrelevant if the Pope were to repent. All he need to do is to design himself as the judge for his case, and take notice that he repented, following the ordinary legal procedures (upon which he has full authority). Yet, if he were not to repent, it could well be the case that the Pope could block an excommunication process against him, or appoint himself as judge and dictate in favour of himself (e.g. that he was not aware of the penalties), and thus, there would be no excommunication. In other words, even if he committed a sin such a s to deserve excommunication, he might not excommunicate himself. Therefore, nothing will happen.
On the other hand, if the excommunication were to be automatic (latae sententiae), then, as point 1.3 of Canon 1331 states, an excommunicated person is forbidden:
to exercise any ecclesiastical offices, ministries, or functions whatsoever or to place acts of governance.
This is the real conundrum. The See of Rome is de facto without a Bishop. More importantly, as explained in this answer, most of dioceses have an adjunct bishop, which takes office if the principal bishop leaves the place (e.g. if he dies). However, precisely because the See of Rome is the primus inter pares, and the see of the Pope, this one does not have an adjunct bishop! In other words, the See of Rome would be sede vacante! This means a new process for electing a pope must take place.
However, recall again that the excommunicated Pope (so no longer the Pope) can repent, and ask to the corresponding authorities (in order to make the process valid under the Canon Law) for reintroduction into the Church. Only if he is not willing to repent then the election process would go ahead. It would not be the first time in history where one "invalid Pope" claims to be the real Pope. Now, if a new Pope is elected and then the old one decides to ask for repentance, then that would be the ultimate bug in the software. Surely God will spare the Church from that ever occurring!
A Pope is not subject to canon law
Can. 1404 The First See is judged by no one.
Canonist Charles Augustine, O.S.B., D.D., comments on the 1917 Code's equivalent canon (can. 1556) in his A Commentary on the New Code of Canon Law vol. 7, p. 11-12:
Exemption of the Pope
Prima Sedes a nemine iudicatur.
The first or primatial see is subject to no one's judgment. This proposition must be taken in the fullest extent, not only with regard to the object of infallibility. For in matters of faith and morals it was always customary to receive the final sentence from the Apostolic See, whose judgment no one dared to dispute, as the tradition of the Fathers demonstrates.1 Neither was it ever allowed to reconsider questions or controversies once settled by the Holy See.2 But even the person of the Supreme Pontiff was ever considered as unamenable to human judgment, he being responsible and answerable to God alone, even though accused of personal misdeeds and crimes. A remarkable instance is that of Pope [St.] Symmachus (498-514). He, indeed, submitted to the convocation of a council (the Synodus Palmaris, 502), because he deemed it his duty to see to it that no stain was inflicted upon his character, but that synod itself is a splendid vindication of our canon. The synod adopted the Apology of Ennodius of Pavia, in which occurs the noteworthy sentence:
God wished the causes of other men to be decided by men; but He has reserved to His own tribunal, without question, the ruler of this see.3
No further argument for the traditional view is required. A general council could not judge the Pope, because, unless convoked or ratified by him, it could not render a valid sentence.Hence nothing is left but an appeal to God, who will take care of His Church and its head.
Also, 1917 Canon 219:
The Roman Pontiff, legitimately elected, immediately upon accepting the election, obtains by divine law the full power of supreme jurisdiction.
No latæ sententiæ deposition in current Canon law
Even if a pope could incur excommunication, he, being Bishop of Rome, would still occupy his see until deposed.
cf. Can the Pope Go Bad? p. 43 fn. 15
As CIC can. 1331 states, an excommunicated cleric loses the permission to exercise his functions and to celebrate sacraments. So if the pope falls into excommunication latae sententiae (this is the only relevant scenario because otherwise the pope would have to judge himself, which is clearly not possible), he may not do his job any more.
He may resume his job if he repents. Until then, he is still bishop of Rome, as a valid consecration cannot become invalid. He may not exercise his office, but in terms of administering sacraments, he can still continue: His consecrations of other clerics will be valid, but unapproved (like the consecrations Lefèbvre did; he was excommunicated in 1988 but still consecrated validly clerics).
Other ecclesiastical offices than (unallowedly) administering sacraments will be invalid. He has no authorization to them. These duties will have to be fulfilled by others or --if they have to be done by the pope himself-- they will not be done. The latter is very unconfortable for the church, even for the pope himself. So there is much incentive for others to encourage the pope to repent and even incentive to the pope himself: One of his offices is to put his own personal expenses on the church's bill, so an excommunicated pope without other "secular" income will struggle to make a living.
Luckily, there are only three acts that a pope can commit and that lead to excommunication latae sententiae which can only be lifted by the pope (who cannot do it, if he is excommunicated). These are sacrilege, breaking the seal of the confessional and giving (invalid) absolution to a person he committed adultery with. Also, these things have to be committed knowing they are illegal. In his position, I think every pope is old enough not to do either of them if he is aware of the consequences.
The other acts requiring papal lift of excommunication (like violence against the pope, tampering the conclave or doing something without the pope's permission) cannot be commited by the serving pope himself, of course. So practically, an excommunicated pope will always find a bishop in curia who may lift his excommunication upon repentence.
However, note that even popes confess their sins to other priests (or bishops). So even to the pope the canon applies that he may not administer or receive sacraments if he has a severe sin on his conscience. But he'll quickly get an appointment for confession, of course, and things will be settled.
Historically, there is only one well-known example of papal excommunication: The one of 1054. From that time on, the Roman pope has not been mentioned in the divine liturgie any more. Among the church that excommunicated him, it had no more canonical consequences as Constantinople's church already considered itself as independent (autocephalous) since a council with Rome (John VIII.) from 879.
So probably, if the pope becomes excommunicated nowadays latae sententiae in the Catholic church and if it will become noticed, he will not be mentioned in the Holy Mass until he repents. But there is no indication that he will actually loose his position permanently, e.g. there will be no urgent need for a conclave.
I will answer the imaginary question on two ways, one is biblical and the other is by citing the church critics and enemies.
It's not a commonly accepted that a Pope can lose the office via heresy for the prime reason that those who accuse the Pope of heresy must be a member of the Church (Clergy and faithfuls). But the most that they can do is seek clarification following the evangelical guidelines of Donum Veritatis.
The problem of the accuser in the Church right now is the one who accuse Pope Francis for example is they are bound by Canon 751 which manifested in their opposition and unsubmission to Papacy. Therefore they are the one who incurs automatic excommunication first. And ceases to be a Church member anymore and had no right in participating in the life of the Church.
The Catechism of the Catholic Church defines these three sins against the faith in this way:
2089 Incredulity is the neglect of revealed truth or the willful refusal to assent to it.
"Heresy is the obstinate post-baptismal denial of some truth which must be believed with divine and catholic faith, or it is likewise an obstinate doubt concerning the same;
apostasy is the total repudiation of the Christian faith;
schism is the refusal of submission to the Roman Pontiff or of communion with the members of the Church subject to him." [Code of Canon Law c.751]
Church Crisis of confusion today regarding Pope Francis can be traced to church critics and enemies. As Pope Francis simply said "we know them". Pope Francis warn us of "fake news & gossiping" the deceptive tool that most of the accuser of Papal heresies uses in this times. This group of accuser are schismatics as Stephen Walford even said kinda "satanic in nature" and therefore by their actions they cease to be a member of Church anymore and by Canon law are guilty of schism incurs automatic excommunication.
“The abuse from many, including those who run websites and Traditionalist blogs aimed at the Holy Father and those who are loyal to him, is nothing short of satanic. You are their role models and that is an intolerable situation. In reality, there is no confusion but only outright rejection and defiance towards the legitimate Pope and his magisterial teachings.”
When it comes to Catholics who are formally guilty of heresy, apostasy or schism, the Church applies the penalty of excommunication. The 1983 Code of Canon Law, repeating the sanctions of the earlier 1917 Code, states,c. 1364
With due regard for can. 194, part 1, n. 2, an apostate from the faith, a heretic or a schismatic incurs automatic (latae sententiae) excommunication and if a cleric, he can also be punished by the penalties mentioned in can. 1336, part 1, nn. 1, 2, and 3.
If long lasting contumacy or the seriousness of scandal warrants it, other penalties can be added including dismissal from the clerical state. This canon is saying that once a person willingly repudiates Christ, embraces a heresy, knowing it to be contrary to divine and Catholic faith, or refuses submission to the Roman Pontiff (or communion with the members of the Church subject to him), by virtue of the law itself they are automatically excommunicated. No ecclesiastical act is necessary and no public notice.
To answer biblically, I will cite the faith condition of Peter prior to Jesus appointing him as Pontiff and prior to receiving the anointing of gifts of the Holy Spirit at the Upper Room.
Peter like the rest of Apostles and Disciples are subject to satan attacks and can be subject to satan cunning deception and evil inspirations as seen in Matthew16:23
"But Jesus turned and said to Peter, “Get behind Me, Satan! You are a stumbling block to Me. For you do not have in mind the things of God, but the things of men.”
We can see Peter thoughts was inspired by satan himself.
Jesus knowing the vulnerabilty of Apostles to satan deception and attacks. a After appointing Peter, by giving him the Key to the Kingdom had promised two powerful protection.
One directly to Peter (Luke 22:32) and the other to the Church (Matthew16;18)
"But I have prayed for you, Simon, that your faith may not fail. And when you have turned back, strengthen your brothers.”(Luke22:32)
"And I say to thee: That thou art Peter; and upon this rock I will build my church, and the gates of hell shall not prevail against it."(Matthew16:18)
Also, we can see in Acts Chapter 5, Peter was indwelt by the Holy Spirit, a lie spoken to Peter is a lie spoken directly to the Holy Spirit.
Then Peter said, “Ananias, how is it that Satan has filled your heart to lie to the Holy Spirit and withhold some of the proceeds from the land? (Acts5:3)
So biblically speaking Peter was protected by Jesus powerful promised of protection in Luke22:32 and as Vicar of Christ the Papacy is indwelt and guided by the Holy Spirit in Acts5:3.
Not only that, Traditions upheld that a Pope cannot teach errors in matters of "faith & morals"
In a letter addressed to Dubia Cardinals by Stephen Walford, he enumerates the solid foundation that a Pope is guided by the Holy Spirit in teaching the flock.
Your Eminences, I would like to draw your attention to the teachings found in several magisterial documents of great importance.
In Donum Veritatis (no 17) we read: “It is also to be borne in mind that all acts of the Magisterium derive from the same source, that is, from Christ who desires that His People walk in the entire truth. For this same reason, magisterial decisions in matters of discipline, even if they are not guaranteed by the charism of infallibility, are not without divine assistance and call for the adherence of the faithful.” Pope Leo XIII in his Encyclical Satis Cognitum stated: “This metaphorical expression of binding and loosing indicates the power of making laws, of judging and of punishing; and the power is said to be of such amplitude and force that God will ratify whatever is decreed by it. Thus it is supreme and absolutely independent, so that, having no other power on earth as its superior, it embraces the whole Church and all things committed to the Church.” I would humbly suggest that we cannot come to any other conclusion than Pope Francis– as the beneficiary of the Holy Spirit’s charism of assistance even in his ordinary magisterium— (as taught by St. John Paul II) has legitimately made possible the reception of Holy Communion for the divorced and remarried in certain carefully considered cases where grace is working in their souls, and a sincere desire to strive for holiness is present. If we cannot accept this premise, then we are not accepting the teachings of previous popes. If Tradition teaches us one thing, there is a hermeneutic of continuity in understanding the spiritual authority of the papacy in matters of faith and morals, and as the First Vatican Council pointed out: “Indeed, their apostolic teaching was embraced by all the venerable fathers and reverenced and followed by all the holy orthodox doctors, for they knew very well that this See of St. Peter always remains unblemished by any error.” Pope Innocent III stated: “The Lord clearly intimates that Peter’s successors will never at any time deviate from the Catholic faith, but will instead recall the others and strengthen the hesitant” (Apostolicae Sedis Primatus), while Pope Benedict XVI taught: “the Petrine ministry is a guarantee of freedom in the sense of full adherence to the truth, to the authentic tradition, so that the People of God may be preserved from errors concerning faith and morals”(Homily for the Feast of St. Peter and Paul, 2010)
Lastly, to entertain your imaginary acts that a Pope can commits "what happens if a pope commits a sin other than heresy, such as abortion or violating the seal of confession, which carries an equal penalty?Is the Pope subject to the automatic excommunication? If so, would the election of a new Pope be called for?
Personally viewing the scenario if Pope Francis commits the imaginary acts you've presented.(it's hypothetical but for the sake of entertaining your question based on "what if".)
One scenario is, the Clergy and Church faithful loyal to Pope Francis would first seek clarification guided by Donum Veritatis and will show first and foremost love, mercy and compassion and follow Jesus words on Matthew7:1 "Do not judge". Also, this would mean Jesus failed on His powerful promised of protection to His Church and Vicar of Christ would reflect deeply first thru prayers and silence.
Second scenario, the church critics and enemies would push for Pope ouster and schismatics would spearheaded the call for election. Since the Pope election will be initiated by schismatics, church critics and enemies the elected Pope is surely an Apostate Pope by virtue of the people characters behind the ouster.
(Note: this is also a hypothetical answer based on your imaginary question)
In conclusion, since the question is an imaginary acts the Biblical promised of Jesus prevails. Luke 22:32 and Matthew16:18 must be embraced and upheld.**
"The gates of hell shall not prevails against it!"(Matthew16:18)
The question if a Pope can be automatically excommunicated, therefore in the heart of the Church Doctrine does not exists as no one can judge the action of the Pope, and the Pope is directly answerable to God.
The Donum Veritatis serves to protect the Church and Pope from evil attack by adhering to Evangelical Guidelines in the spirit of charity & humility.
We should be guided by Motter Vugel revelation;"Mutter Vogel's Worldwide Love,St.Grignion Publishing House,Altotig,south Germany(29,6.1929)
"NEVER ATTACK A PRIEST" (Pieta Prayer booklet;page 68) much more a Vicar of Christ.