SAN FRANCISCO — A man who tricked a woman into thinking he was her boyfriend did not commit rape by having sex with her, the Second District Court of Appeal ruled Wednesday in an early candidate for weirdest fact pattern of 2013.

“Because of historical anomalies in the law and the statutory definition of rape,” Justice Thomas Willhite Jr. wrote, sex-by-impersonation is not rape, “even though, if the woman had been married and the man had impersonated her husband, the answer would be yes.”