An appeal may be taken from a judgment or order, in an infraction or misdemeanor case, to the appellate division of the superior court of the county in which the court from which the appeal is taken is located, in the following cases:
(a) By the people:
(1) From an order recusing the district attorney or city attorney pursuant to Section 1424.
(2) From an order or judgment dismissing or otherwise terminating all or any portion of the action, including such an order or judgment, entered after a verdict or finding of guilty or a verdict or judgment entered before the defendant has been placed in jeopardy or where the defendant has waived jeopardy.
(3) From sustaining a demurrer to any portion of the complaint or pleading.
(4) From an order granting a new trial.
(5) From an order arresting judgment.
(6) From any order made after judgment affecting the substantial rights of the people.
(7) From the imposition of an unlawful sentence, whether or not the court suspends the execution of sentence. As used in this paragraph, “unlawful sentence” means the imposition of a sentence not authorized by law or the imposition of a sentence based upon an unlawful order of the court that strikes or otherwise modifies the effect of an enhancement or prior conviction. A defendant shall have the right to counsel in the people’s appeal of an unlawful sentence under the same circumstances that he or she would have a right to counsel under subdivision (a) of Section 1238.
(8) Nothing in this section shall be construed to authorize an appeal from an order granting probation. Instead, the people may seek appellate review of any grant of probation, whether or not the court imposes sentence, by means of a petition for a writ of mandate or prohibition that is filed within 60 days after probation is granted. The review of any grant of probation shall include review of any order underlying the grant of probation.
(b) By the defendant:
(1) From a final judgment of conviction. A sentence, an order granting probation, a conviction in a case in which before final judgment the defendant is committed for insanity or is given an indeterminate commitment as a mentally disordered sex offender, or the conviction of a defendant committed for controlled substance addiction shall be deemed to be a final judgment within the meaning of this section. Upon appeal from a final judgment or an order granting probation the court may review any order denying a motion for a new trial.
(2) From any order made after judgment affecting his or her substantial rights.
(Amended by Stats. 2011, Ch. 304, Sec. 11. (SB 428) Effective January 1, 2012.)