Use modern `except` syntax

The `except Exception as e` form is preferred over the older `except Exception, e` form, as it works in both Python 2 and 3.
Merge modern exception syntax patch.