python 3 exceptions compatibility