Changes in exception handling code for python 3