Fixed exceptions in python