Make raised exceptions Python 3 compatible