Every person who rescues or attempts to rescue, or aids another person in rescuing or attempting to rescue any prisoner from any prison, or prison road camp or any jail or county road camp, or from any officer or person having him or her in lawful custody, is punishable as follows:
(a)
If the prisoner was in custody upon a conviction of a felony punishable with death, by imprisonment pursuant to subdivision (h) of Section 1170 for two, three or four years.
(b)
If the prisoner was in custody otherwise than as specified in subdivision (a), by imprisonment pursuant to subdivision (h) of Section 1170, or by imprisonment in the county jail not to
exceed one year.