Make exception handling compatible with Python 2.5

This is a short term fix suggested by Peter Chater on the mailing list that will allow the code to be used with Python 2.5 - a better solution will be needed when we merge in the Python 3.0 support