Unfortunately, the British-drafted Indian Penal Code criminalized aspects of human behaviour and human reality that in India had not previously been regarded as criminal or requiring legal sanction.
While this may be true, alternative sexual or gender identities were still subject to social discrimination - much like the caste system