Use the newer python syntax for exceptions

We've dropped support for python 2.5, so now we can use the forward
compatible "except ... as" syntax.