Pope Adrian VI († 1523) stated that “it is beyond question” that a pope can “err in matters touching the Faith”, he can “teach heresy” in decrees. He also stated “many Roman Pontiffs were heretics”.
“If by the Roman Church you mean its head or pontiff, it is beyond question that he canerr even in matters touching the faith. He does this when he teaches heresy by his own judgement or decretal. In truth, many Roman pontiffs were heretics. The last of them was Pope John XXII († 1334).” (Quaest. in IV Sent.; quoted inViollet, Papal Infallibility and the Syllabus, 1908).*
(* According to the 1907 Catholic Encyclopedia, this work was published in 1512 from the notes of his student and without his supervision, but as it saw “many editions” it would appear that the pope did not repudiate the passage as not his own, in a work attributed to him.)
Venerable Pope Pius IX († 1878)recognized the danger that a future pope would be a heretic and “teach contrary to the Catholic Faith”, and he instructed, “do not follow him.”
“If a future pope teaches anything contrary to the Catholic Faith, do not follow him.” (Letter to Bishop Brizen)
Pope Adrian II († 872) admitted that papal heresy “renders lawful the resistance of subordinates to their superiors, and their rejection of the latter's pernicious teachings.”
“We read that the Roman Pontiff has always possessed authority to pass judgment on the heads of all the Churches (i.e., the patriarchs and bishops), but nowhere do we read that he has been the subject of judgment by others. It is true that Honorius was posthumously anathematized by the Eastern churches, but it must be borne in mind that he had been accused of heresy, the only offense which renders lawful the resistance of subordinates to their superiors, and their rejection of the latter's pernicious teachings”.
However, I must disagree with Pope Adrian when he said that heresy was the only offense that justified resistance: the Saints and Doctors have informed us otherwise, as we shall see.
Further, Pope Honorius I († 638)was not merely “accused of heresy” or “anathematized by the Eastern Churches”: he was anathematized as a heretic by the ecuмenical Council of III Constantinople, whose Acts were confirmed by Pope Leo II († 683).
“We foresaw that, together with them, also Honorius, before Pope of Old Rome, is cast out of the Holy Catholic Church of God and anathematized, for we have found by his writings sent to [the heretic] Sergius, that he followed the thinking of the latter in everything, and continued his impious principles. […] To Sergius, the heretic, anathema! To Cyrus, the heretic, anathema! To Honorius, the heretic, anathema!”
NOTE: So we see that popes have told us that a pope can “wither away into heresy” and “not believe” the Faith; that “it is beyond question” that a pope can “err in matters touching the Faith”, he can “teach heresy” in decrees; that “many Roman Pontiffs were heretics”; that a pope may be a heretic and “teach […] contrary to the Catholic Faith”, in which case we are to follow the instruction “do not follow him”; and that papal heresy “renders lawful the resistance of subordinates to their superiors, and their rejection of the latter's pernicious teachings.”