Adapt exception handling to new Algorithm API

The algorithm exception handling API changed in the process of porting
to Python 3. We now get just an exception object in our exception
handlers, not a full exc_info-ish tuple.