Upon a plea of guilty to an information or indictment accusing the defendant of a crime or attempted crime divided into degrees when consented to by the prosecuting attorney in open court and approved by the court, such plea may specify the degree thereof and in such event the defendant cannot be punished for a higher degree of the crime or attempted crime than the degree specified.
Ca. Pen. Code § 1192.1