SACRAMENTO — California inmates can now possess marijuana without facing legal consequences from the state’s health and safety code as long as they don’t consume it, thanks to a new appeals court ruling.

The 3rd District Court of Appeal overturned criminal convictions of five Sacramento defendants who had been caught with marijuana in their prison cells. The 20-page ruling says, “Consumption, not possession, is the act voters determined should remain criminalized if the user is in prison.”

The reason? The authors of California Proposition 64 — which voters passed in 2016 allowing recreational marijuana use — did not write in anything that outlaws marijuana possession for incarcerated folks, the court ruled.

But the ruling comes with a major caveat: Consumption of marijuana by California prisoners remains a violation of the state penal code, and possession can still be punished as a rule violation by the California Department of Corrections. But if inmates wants to keep a jar of weed next to their bunk, the district attorney can’t file charges, according to the ruling.

“The question of law we review de novo is whether the plain language of the statute leads to an absurd result. We conclude it does not,” the appeals court judges wrote in their decision. “A result is not absurd because the outcome may be unwise.”

The attorney general’s office could appeal the decision to the California Supreme Court.

But even if California inmates are free from state-level prosecution, there are still consequences for possessing marijuana: Prisoners can get in administrative trouble for it, which could result in good behavior credits revoked or even time in segregated housing.

Smuggling marijuana into prisons, and smoking, eating or otherwise consuming it remains a crime. And of course, prisoners could open themselves up to federal prosecution by possessing it.

“It may be legal, but you can still ban it. Cellphones are legal. Pornographic images are legal. You can’t have either one in prison,” Lafayette attorney Dan Horowitz said.

Horowitz joked that the ruling, “may make Saturday night movies at low-security prisons much more entertaining,” but added there was a more serious issue at play: the fact the consequences for marijuana possession have become so drastically different throughout the United States. While Californians are toking it up, people in some other states can be convicted of a felony for the same conduct.

“I have a client who’s facing life in prison for allegedly shipping marijuana to Missouri, yet California inmates can have it in their prison cells. It’s insane,” he said.

Read the entire 20-page ruling HERE.