Changed exception syntax to be compatible with Python 3