ENCYCLICAL OF POPE LEO XIII ON Fɾҽҽmαsσɳɾყ APRIL 20, 1884
4. The Roman Pontiffs Our predecessors, in their incessant watchfulness over the safety of the Christian people, were prompt in detecting the presence and the purpose of this capital enemy immediately it sprang into the light instead of hiding as a dark conspiracy; and, moreover, they took occasion with true foresight to give, as it were on their guard, and not allow themselves to be caught by the devices and snares laid out to deceive them.
5. The first warning of the danger was given by Clement XII in the year 1738,[3] and his constitution was confirmed and renewed by Benedict XIV.[4] Pius VII followed the same path;[5] and Leo XII, by his apostolic constitution, Quo Graviora,[6] put together the acts and decrees of former Pontiffs on this subject, and ratified and confirmed them forever. In the same sense spoke Pius VIII,[7] Gregory XVI,[8] and, many times over, Pius IX.[9]
6. For as soon as the constitution and the spirit of the masonic sect were clearly discovered by manifest signs of its actions, by the investigation of its causes, by publication of its laws, and of its rites and commentaries, with the addition often of the personal testimony of those who were in the secret, this apostolic see denounced the sect of the Freemasons, and publicly declared its constitution, as contrary to law and right, to be pernicious no less to Christendom than to the State; and it forbade any one to enter the society, under the penalties which the Church is wont to inflict upon exceptionally guilty persons. The sectaries, indignant at this, thinking to elude or to weaken the force of these decrees, partly by contempt of them, and partly by calumny, accused the sovereign Pontiffs who had passed them either of exceeding the bounds of moderation in their decrees or of decreeing what was not just. This was the manner in which they endeavored to elude the authority and the weight of the apostolic constitutions of Clement XII and Benedict XIV, as well as of Pius VII and Pius IX.[10] Yet, in the very society itself, there were to be found men who unwillingly acknowledged that the Roman Pontiffs had acted within their right, according to the Catholic doctrine and discipline. The Pontiffs received the same assent, and in strong terms, from many princes and heads of governments, who made it their business either to delate the masonic society to the apostolic see, or of their own accord by special enactments to brand it as pernicious, as, for example, in Holland, Austria, Switzerland, Spain, Bavaria, Savoy, and other parts of Italy.
Entire docuмent
http://www.papalencyclicals.net/Leo13/l13human.htm So why then did John Paul II new Canon Law lift the excommunication of Freemasons.