Updated exception handling to Python 2.6 syntax