Replacing old and deprecated raise Exception style (PEP8)