Fix exception for use with python3