Fix exception_to_str to work on Python 2.x