Napoleonic Code
Homosexuality is legal in Mexico City since the country's adoption of the Napoleonic Code (via the brief French occupation of Mexico (1862–67)).