California Codes homeSearch California
Cal. CodesPenal CodePart 1. Of Crimes and PunishmentsTitle 7. Of Crimes Against Public JusticeChapter 7. Other Offenses Against Public Justice

Cal. Penal Code § 171b (2026)

Edition and currency
leginfo export of Nov. 23, 2026: changes through Nov. 11, 2026 (checked Nov. 24, 2026). The text is the edition Syfert holds; for a past event, check the version in force on that date.
Other sources
CURRENTleginfo export of Nov. 23, 2026: changes through Nov. 11, 2026 (checked Nov. 24, 2026) cited 1987–2021 11citing cases
At a glance

Courts have cited this section in 11 opinions since 1987, 1 of them in the last five years.

(a)Any person who brings or possesses within any state or local public building or at any meeting required to be open to the public pursuant to Chapter 9 (commencing with Section 54950) of Part 1 of Division 2 of Title 5 of, or Article 9 (commencing with Section 11120) of Chapter 1 of Part 1 of Division 3 of Title 2 of, the Government Code, any of the following is guilty of a public offense punishable by imprisonment in a county jail for not more than one year, or in the state prison:

(1)Any firearm.

(2)Any deadly weapon described in Section 17235 or in any provision listed in Section 16590.

(3)Any knife with a blade length in excess of four inches, the blade of which is fixed or is capable of being fixed in an unguarded position by the use of one or two hands.

(4)Any unauthorized tear gas weapon.

(5)Any taser or stun gun as defined in Section 244.5.

(6)Any instrument that expels a metallic projectile, such as a BB or pellet, through the force of air pressure, CO2 pressure, or spring action, or any spot marker gun or paint gun.

(b)Subdivision (a) shall not apply to, or affect, any of the following:

(1)A person who possesses weapons in, or transports weapons into, a court of law to be used as evidence.

(2)(A)A duly appointed peace officer as defined in Chapter 4.5 (commencing with Section 830) of Title 3 of Part 2, a retired peace officer with authorization to carry concealed weapons as described in Article 2 (commencing with Section 25450) of Chapter 2 of Division 5 of Title 4 of Part 6, a full-time paid peace officer of another state or the federal government who is carrying out official duties while in California, or any person summoned by any of these officers to assist in making arrests or preserving the peace while they are actually engaged in assisting the officer.

(B)Notwithstanding subparagraph (A), subdivision (a) shall apply to any person who brings or possesses any weapon specified therein within any courtroom if they are a party to an action pending before the court.

(3)A person holding a valid license to carry the firearm pursuant to Chapter 4 (commencing with Section 26150) of Division 5 of Title 4 of Part 6 who possesses the firearm within a building designated for a court proceeding, including matters before a superior court, district court of appeal, or the California Supreme Court, and is a justice, judge, or commissioner of the court.

(4)A person who has permission to possess that weapon granted in writing by a duly authorized official who is in charge of the security of the state or local government building.

(5)A person who lawfully resides in, lawfully owns, or is in lawful possession of, that building with respect to those portions of the building that are not owned or leased by the state or local government.

(6)A person licensed or registered in accordance with, and acting within the course and scope of, Chapter 11.5 (commencing with Section 7512) or Chapter 11.6 (commencing with Section 7590) of Division 3 of the Business and Professions Code who has been hired by the owner or manager of the building if the person has permission pursuant to paragraph (5).

(7)(A)A person who, for the purpose of sale or trade, brings any weapon that may otherwise be lawfully transferred, into a gun show conducted pursuant to Article 1 (commencing with Section 27200) and Article 2 (commencing with Section 27300) of Chapter 3 of Division 6 of Title 4 of Part 6.

(B)A person who, for purposes of an authorized public exhibition, brings any weapon that may otherwise be lawfully possessed, into a gun show conducted pursuant to Article 1 (commencing with Section 27200) and Article 2 (commencing with Section 27300) of Chapter 3 of Division 6 of Title 4 of Part 6.

(c)As used in this section, “state or local public building” means a building that meets all of the following criteria:

(1)It is a building or part of a building owned or leased by the state or local government, if state or local public employees are regularly present for the purposes of performing their official duties. A state or local public building includes, but is not limited to, a building that contains a courtroom.

(2)It is not a building or facility, or a part thereof, that is referred to in Section 171c, 171d, 626.9, 626.95, or 626.10 of this code, or in Section 18544 of the Elections Code.

(3)It is a building not regularly used, and not intended to be used, by state or local employees as a place of residence.

The 11 cases that cite Cal. Penal Code § 171b most heavily, weighted by court and treatment. RelevanceNewestTreatment
cites § 171b 6×cited by 102 cases
Where it cites § 171b
“4th 875 (Nordyke), a state statute, Penal Code section 171b, made it a crime to possess firearms in any state or local public building, but exempted a person who, for the purpose of sale or trade, brought an otherwise lawfully possessed firearm into a gun show conducted in…”
The case’s holding
State medical marijuana statutes do not preempt local land use regulations or the authority of municipalities to prohibit medical marijuana dispensaries through zoning or nuisance ordinances.
Later courts cite it for
“the ordinance directly requires what the state statute forbids or prohibits what the state enactment demands.” · 5 citing courts
2
GREENZelig v. Cnty. of Los Angeles, 27 Cal. 4th 1112 (2002).
cites § 171b 2×cited by 502 cases
Where it cites § 171b
“” (The parties agree that signs are posted in the courthouse stating that Penal Code section 171b prohibits persons from bringing weapons into the courthouse.”
The case’s holding
Public entities and law enforcement officers generally owe no duty to protect individuals from third-party criminal acts unless a special relationship exists or the state affirmatively creates the danger.
Later courts cite it for
“our standard of review is clear: ' "we treat the demurrer as admitting all material facts properly pleaded, but not contentions, deductions or conclusions of fact or law. we also consider matters which may be judicially noticed.” · 42 citing courts
3
GREENNordyke v. King, 27 Cal. 4th 875 (2002).
cites § 171b 5×cited by 21 cases
Where it cites § 171b
“County property did not include any “ local public building’ ” as defined in Penal Code section 171b, subdivision (c).”
The case’s holding
State law regulating firearms does not preempt a local ordinance prohibiting gun possession on county property insofar as the ordinance concerns gun shows.
Later courts cite it for
“does state law regulating the possession of firearms and gun shows preempt a municipal ordinance prohibiting gun possession on county property.” · 2 citing courts
4
GREENConejo Wellness Ctr., Inc. v. City of Agoura Hills, 214 Cal. App. 4th 1534 (Ct. App. 2013).
cites § 171b 4×cited by 21 cases
Where it cites § 171b
“Section 171b, subdivision (b)(7), exempts from the prohibition persons bringing firearms for lawful sale or trade into a gun show otherwise lawful under state law.”
Later courts cite it for
“summary judgment or summary adjudication is appropriate when no triable issue of material fact remains and the moving party is entitled to judgment or adjudication as a matter of law. a trial court's decision on a motion for summary judgment or summary adjudication is reviewed de novo, viewing the evidence in the light most favorable to the nonmoving party.” · 2 citing courts
5
GREENFurey v. Comm'n on Jud. Performance, 43 Cal. 3d 1297 (1987).
cites § 171b 1×cited by 43 cases
Where it cites § 171b
“Petitioner promptly found Hamilton in violation of Penal Code section 171b, which prohibits bringing into a courtroom a knife with a blade in excess of four inches, and had him remanded, setting bail at $10,000.”
The case’s holding
Judicial discipline is an art rather than a science that depends on the specific facts presented in each case (sanctioning turns on the facts presented in each case).
Later courts cite it for
“the number and quality of the charges found to be true assumes importance as one of the guidelines we apply in making the difficult decision of discipline” · 1 citing court
6
GREENPeople v. Mesce, 52 Cal. App. 4th 618 (Ct. App. 1997).
cites § 171b 1×cited by 20 cases
Where it cites § 171b
“Code, § 140); bringing a weapon into a public building or meeting (Pen. Code, § 171b); possessing a loaded firearm in a state office, the capitol grounds, or school grounds (Pen.”
Later courts cite it for
“looking to the past to inform the present,” · 2 citing courts
7
NO FLAGUntitled California Attorney Gen. Opinion, No. 88-1201 (Cal. Att'y Gen. July 6, 1989).
cites § 171b 7×cited by 0 cases
Where it cites § 171b
“Does Penal Code section 171b prohibit such officers from carrying a firearm into a courthouse in the performance of their duties? 3.”
8
NO FLAG420 Caregivers v. City of LA, No. B230436A (Cal. Ct. App. Sept. 25, 2013).
cites § 171b 4×cited by 0 cases
Where it cites § 171b
“) Plaintiffs, who were gun show promoters, sought to enjoin the ordinance, relying in part on Penal Code section 171b.”
9
GREENNordyke v. King, 27 Cal. 4th 875 (2002).
cites § 171b 5×cited by 0 cases
Where it cites § 171b
“County property *765 did not include any "`local public building'" as defined in Penal Code section 171b, subdivision (c).”
10
NO FLAGIn re R.W. ca4/3, No. G058884 (Cal. Ct. App. Oct. 19, 2020).
cites § 171b 1×cited by 0 casesunpublished
Where it cites § 171b
“Prior to the jurisdiction hearing, mother was arrested for possession of a weapon in a state or local public building (Pen. Code, § 171b, subd. (a)). She pleaded guilty and was sentenced to 10 days in county jail.”
11
NO FLAGIn re C.A. ca4/3, No. G059464 (Cal. Ct. App. Mar. 3, 2021).
cites § 171b 1×cited by 0 casesunpublished
Where it cites § 171b
“Prior to the jurisdiction hearing, mother was arrested for possession of a weapon in a state or local public building (Pen. Code, § 171b, subd. (a)). She pleaded guilty and was sentenced to 10 days in county jail.”

The flag is Syfertize’s treatment of the citing case itself, not of the statute. “Where it cites” is the passage in the opinion; the holding is a summary of the whole case and may concern another point. Annotations are extracted automatically from the opinions in the Syfert caselaw corpus.

Citing cases by year
198720042021

One bar per year. Tallest: 3 cases in 2002. These are opinions in the Syfert collection, which holds more of some courts’ recent opinions than their older ones, so a rise can reflect what the collection holds and not more litigation.

By court
Cal.5Cal. Ct. App.5Cal. Att'y Gen.1
By subsection

Courts have not cited this section by subsection, so its cases are not split up here. The Leading cases tab lists the cases that cite it most heavily.

Enactment and amendments
Amended by Stats. 2023, Ch. 249, Sec. 2. (SB 2) Effective January 1, 2024.
Versions

Edition shown: leginfo export of Nov. 23, 2026: changes through Nov. 11, 2026 (checked Nov. 24, 2026). Syfert holds no earlier or later version of this section.

California Codes Home  |  Search California  |  Search cases for this section  |  syfert.com