Fix exception formatting for Python 3.