Don't use deprecated syntax for "except"

http://docs.python.org/3.3/howto/pyporting.html#capturing-the-currently-raised-exception

And remove trailing whitespace.