modified exception to support python 3