If a pope is a heretic he is an antipope, then all this actions, canonizations, dogmas etc. are non-binding.
we are made aware of heresies of JPII by media. It follows that in past centuries, people couldn't always notice if a pope said anything heretical.
Now how can you be so sure that for example the popes who declared dogmas like perpetual virginity of our Lady and EENS hadn't said or done anything heretical that wasn't written?
What if those popes who made councils of Trent and Lateran and canon of scripture were guilty of some heresy without anybody knowing it?
So is there any 1% possibilty that dogmas be false since the popes who declared them could 1% be heretics?
You see that it is a fallacy