A boy in Palmdale who was playing cops and robbers with a toy gun was shot and wounded Sunday night by a Los Angeles County sheriff’s deputy, authorities said.

The boy was shot in the upper torso and was expected to survive, said Deputy Ed Hernandez, a sheriff’s spokesman. He declined to release the victim’s name or age.

Hernandez said that deputies responded about 8 p.m. to reports of a person brandishing a weapon and that the suspect pointed the gun at the officers.

“The deputies, fearing for their life, shot him once,” Hernandez said. “Later on, they determined it was a juvenile playing cops and robbers.”