support both Python 2/3 style exception handling