Changed exception handling syntax to be backward compatible with Python 2.5