Fix exception syntax to be Python 3 compatible