changing 'raise' statements to match both python versions