backported python3 latin1 fix from 1.9