Edit exception handling and raising for python 3