The code you are referring to has been inactive for a long time and appears to be incomplete in the current release. The Person class doesn't have many of the member variables referenced in that code, such as "punish", "praise", or "pussy"; and the "sexuals" variable is currently inactive. "slavedialogues.gd" and "statstab.gd" are the only files still relevant to "person.punish" and neither ever sets it to false, though there is a section under the 'beat' action that appears to be where it should be present.
There is no requirement explicit nor implicit in the active code of the game for a slave to be punished to become obedient or loyal. Having pleasant meet and sex interactions is sufficient to achieve both, though it is often not the fastest approach. Currently the only records of punishments is in the sex experience counts in "person.sexexp", which counts how many times a person has watched, participated in, or orgasmed from an action.