A trans woman who brandished a claw hammer at shop staff could not be jailed because there was no way to confirm her gender.
Leila Le Fey, 40, was spared prison after a judge heard she did not have certified evidence of her gender reassignment and would have had to go to a male-only jail.
Judge Stephen Mooney called Le Fey back to Lewes Crown Court an hour after giving her an "immediate" six-month custodial sentence.
Her barrister, Rebecca Upton, had informed the court that the only way Le Fey could prove her gender would have been to undergo an "undignified examination", one that staff were not prepared to do.
Without certified evidence of Le Fey's gender reassignment, she would have had to be taken to the male-only Lewes Prison - where, Ms Upton said, regulations stated she could not have been kept in solitary confinement. This would have left Le Fey "vulnerable".
Reversing his decision, Judge Mooney said: "Issues have now arisen. We live in a society which acknowledges and embraces diversity and allows and encourages people to live the life they want to.
"Sometimes society does not make the necessary or appropriate adjustments in all ways it can to reflect the adjustments of society as a whole.
"Having reflected again upon the impact an immediate custodial sentence would have, the difficulties there are and the intractable problems the prison service would face, I have reconsidered whether imprisonment must be immediate."
Earlier, Rowan Jenkins, prosecuting, told the court that Le Fey had entered a Budgens store in Queen's Road, Brighton, East Sussex, at 4am on Nov 6 to steal wine. When challenged by manager Enoch Adetayo, who confiscated a bottle of wine from her, she produced the claw hammer and threatened to hit him with it. Le Fey then tried to take another bottle of wine and leave the store, but police arrived and arrested her.
Ms Upton said her client had battled with drink and drug addictions and had kept herself out of trouble since 2014 before a relapse last year.
Judge Mooney said: "When you took out the claw hammer, it must have been terrifying."
Le Fey, of Providence Place, Brighton, admitted common assault and possession of an offensive weapon. She was given a six-month suspended sentence, with 30 rehabilitation sessions.