Well, just had a pretty strange experience in my Milan campaign.
The HRE attacked me (unprovoked) and suddenly I found myself excommunicated and at war with the Papal States too. Although I had near perfect relations with the pope (9 out of 10).

Isn't it the HRE that is supposed to be punished by the pope for attacking me?
It all happened in one AI turn, so I hadn't retaliated against the HRE or anything yet.
The Papal States were allied with the HRE and one of my own allies had just been excommunicated the turn before. :hmmm:
If the pope excommunicates anybody that his allies attacks - well, then being allied with the pope is a pretty potent weapon. And if I am being punished for something my ally did, well, that seems a bit unfair.