Mental health issues shouldn't be seen as a smear though – is it a smear if someone has physical health issues (who doesn't, at least from time-to-time?)
A recent study carried out on behalf of the Australian government estimated that 43% of Australians aged 18-to-65 had experienced mental illness at some time in their lives, and 22% at some time in the last 12 months.
The same study estimates that in the 12 months prior to the study, 17% of Australians had an anxiety disorder, 8% an affective disorder (depression or bipolar), 3% a substance use disorder.
https://www.aihw.gov.au/mental-health/overview/prevalence-an...
If the judge instead said "this guy's not that bad, he's just gay" it wouldn't go over so well.
And if the defence introduces mental health evidence into the sentencing, the judge is legally obliged to rule on it - explaining whether it was accepted or not, and if it was, how big an impact it had on the sentencing decision-if the judge didn’t do that, they risk either party successfully appealing the sentence, in extreme cases even being disciplined.
And even if it is a “plea deal” - the sentencing procedure is fundamentally the same as if there isn’t one, it is just the prosecution commits not to ask for a harsher sentence than agreed, the defence still has to introduce mitigating evidence and the judge has to rule on it; if the defence doesn’t, there’s a risk the judge may decide the agreed sentence is too lenient and overrule the agreement.