And before that it was taught by St. Thomas.
Look, the fact that St Thomas taught it doesn't carry as much weight as you suggest. He's one theologian among 100s. So for you to point him out, as if his opinion is the Church's, is the same as BOD'ers incorrectly elevating St Alphonsus' opinion on BOD.
The facts, so far, that we've uncovered on canonizations are this:
1. There is a NEAR unanimous agreement by theologians that they are infallible. But still, not unanimous.
2. There has been NO clear teaching by the Church that they are infallible.
3. Church officials both before (Pope Leo X) and after (V2 officials posted) Vatican 2 say that canonizations are either 1) a certain truth, or 2) are "definitive" but not infallible.
Previous to V2, the Church used canonizations to declare those in heaven whom She wished to put forth as an example of heroic sanctity. Thus, she only canonized the "cream of the crop".
Post V2, the conciliar Church seems to have taken a liberal approach (shocking!) and has "lowered the bar" to canonize those who did not necessarily live heroicly virtuous lives.
Moral of the story: Canonizations ONLY say that the person is in heaven. It is NOT a condonement, approval or judgement on the sanctity practiced by the individual. Those who infer that the canonized person was "saintly" or "heroicly virtuous" do so only because they
assume the post-V2 purpose in canonizing is the same as the pre-V2 purpose. These purposes are different.
So I can agree that JPII and John XXIII are in heaven, because the Church says so. Does that mean they didn't scandalize, didn't promote heresy, or didn't corrupt Church traditions, etc? No, it just means that the Church is saying they repented of their sins before death and saved their soul. What they did or didn't do in this life, from a moral standpoint, is not part of a canonization (in the V2 Church's view).