Penal Code § 171b PC is the California statute that makes it a crime to bring or possess certain weapons such as guns or knives into
- public buildings or
- meetings open to the public.
Violating 171b PC can be charged as either a
- misdemeanor carrying up to 1 year in jail; or
- felony carrying 16 months, 2 years, or 3 years in jail.

In this article, California criminal defense attorneys will address the following key topics regarding bringing weapons into public buildings and meetings:
- 1. Elements of 171b PC
- 2. Exceptions
- 3. Defenses
- 4. Related Crimes
- Frequently Asked Questions
- Additional Resources
1. Elements of 171b PC
For you to be convicted of violating California Penal Code 171b PC, prosecutors must prove beyond a reasonable doubt that you brought or possessed certain weapons into a public building or a meeting open to the public.1
Some of these prohibited weapons include any:
- firearm,
- knife with a blade length over four inches,
- tear gas,
- taser or stun gun,
- BB gun or pellet gun, and
- spot marker gun or paint gun.2
2. Exceptions
There are some exceptions to the prohibitions in California Penal Code 171b PC. Specifically, you can bring weapons into public buildings and meetings if you either:
- are lawfully transporting weapons into a court of law to be used as evidence, or
- are a police officer, or
- are holding a valid license to carry a firearm, or
- have permission to possess the weapon and are in charge of securing the public building you are in.3
According to PC 171bc, a “public building” is a building owned or leased by the state or local government if state or local public employees are regularly present to perform their official duties.4

PC 171b does not apply to knives with a blade of four inches or less.
3. Defenses
Here at Shouse Law Group, we have represented literally thousands of people charged with weapons crimes such as bringing prohibited weapons into public buildings or meetings. In our experience, the following three defenses have proven very effective with prosecutors, judges, and juries at getting PC 171b charges reduced or dismissed.
1) You Are Exempted from the Law
Recall that certain people are free from prosecution under Penal Code 171b.
For example, police officers may bring “weapons” into public buildings and meetings. It is a defense, therefore, for you to show that you fall into one of these exempted categories.
2) There Was No Unlawful Weapon
Also recall that Penal Code 171b prohibits only the weapons that are specifically listed within the code section.
This means it is always a defense for you to show that the object you had was not an unlawful weapon within the language of the statute. For example, maybe you had a knife with a two-inch blade, and not a four-inch blade.
3) The Police Coerced Your Confession
This defense applies when you were charged under PC 171b following a confession. California law states that police may not use overbearing measures to coerce a confession.
If you can show that the police coerced you into a confession, then:
- the judge may exclude the confession from evidence; or,
- the case could get dropped altogether.

Unless an exception applies, it is a crime to bring a gun into public buildings in California.
4. Related Crimes
Possession of Destructive Devices
Penal Code 18710 PC makes it a California crime to possess a “destructive device.” Destructive devices include things like:
- bombs,
- grenades,
- explosive missiles,
- projectiles containing any kind of explosive or incendiary material, and
- certain rockets and rocket-propelled projectiles.
A violation of PC 18710 can be charged as either a misdemeanor or a felony.5
Illegal Acts with a Cane Sword
Penal Code 2510 PC makes it a California crime to make, import, sell, give, or possess a cane sword.9 A “cane sword” is an object that looks like an ordinary cane but has a concealed sword inside it.
A violation of PC 20510 is a wobbler offense under California law. This means it can be charged as either a misdemeanor or a felony.6
Carrying a Concealed Weapon
California Penal Code 25400 makes it a California crime to do certain acts with a concealed weapon. The prohibited acts are carrying a concealed weapon:
- within a vehicle under your control; or,
- upon your person.
A violation of PC 25400 can be charged as either a misdemeanor or a felony.7

Violating PC 171b is a wobbler offense, meaning it can be a misdemeanor or felony.
Frequently Asked Questions
Is a violation of PC 171b a felony or a misdemeanor?
It is a “wobbler,” meaning California prosecutors can decide to charge it as either a misdemeanor or a felony based on the facts of the case and your criminal history. If charged as a felony, it carries a potential sentence of up to three years in county jail.
Does my CCW permit allow me to carry a gun into a government building?
Technically, PC 171b includes an exemption for valid CCW holders. However, most California courthouses and government centers have independent administrative rules that strictly prohibit firearms for everyone except law enforcement.
While you might not be charged with a crime under PC 171b, you will likely be denied entry or face trespassing charges if you violate those specific building rules.
Are pocketknives allowed in public buildings in California?
Under PC 171b, the ban applies specifically to knives with a blade exceeding four inches that is fixed or capable of being fixed (locking). Smaller folding pocketknives are not unlawful under this specific statute. However, security checkpoints (especially at courthouses) usually have a “zero tolerance” policy and will confiscate any knife regardless of length.
What counts as a “public building” under PC 171b?
The law applies to any building owned or leased by the state or local government where public employees meet with the public to perform their official duties. This includes courthouses, city halls, and state office buildings, but generally excludes federal buildings (which are covered by federal law).
Additional Resources
For more information regarding weapons laws, refer to the following:
- California firearm laws – List compiled by the ATF.
- Bureau of Firearms – Agency with the California Department of Justice.
- California and federal assault weapons laws – Information compiled by the California Attorney General.
Legal References:
- California Penal Code 171b PC.
(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.
See, for example, Nordyke v. King (Cal., 2002) 27 Cal. 4th 875; People v. Garton (2018) 4 Cal. 5th 485. See also May v. Bonta (9th Cir. 2024) 113 F.4th 1139. - See same.
- California Penal Code 171bb PC.
- California Penal Code 171bc PC.
- California Penal Code 16460 PC. California Penal Code 18710 PC.
- California Penal Code 20510 PC. See also California Penal Code 1170(h) PC.
- California Penal Code 25400 PC.