diff options
author | John Szakmeister <john@szakmeister.net> | 2013-08-11 05:51:55 -0400 |
---|---|---|
committer | John Szakmeister <john@szakmeister.net> | 2013-08-11 10:12:25 -0400 |
commit | a248e37ad5b20ead46583afbd2821b9d68c640c8 (patch) | |
tree | c0a4c702d7e1bcd3c410ada90e04748a5b1a5741 /nose/plugins | |
parent | 47c8d89e601e93e0606f810d1cb75f834fd81f77 (diff) | |
download | nose-a248e37ad5b20ead46583afbd2821b9d68c640c8.tar.gz |
Fix #720: nose with detailed errors raises encoding error
In this case, the exception vector being passed in was a string that
contained encoded UTF-8 sequences. It was being converted to unicode
implicitly, which was raising a UnicodeDecodeError because some bytes
were >= 128. Make sure the exception string is converted to unicode
before trying to put the whole thing together.
Thanks to Guillaume Ayoub for the test case.
Diffstat (limited to 'nose/plugins')
-rw-r--r-- | nose/plugins/failuredetail.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/nose/plugins/failuredetail.py b/nose/plugins/failuredetail.py index 4c0729c..6462865 100644 --- a/nose/plugins/failuredetail.py +++ b/nose/plugins/failuredetail.py @@ -7,6 +7,7 @@ debugging information. """ from nose.plugins import Plugin +from nose.pyversion import exc_to_unicode, force_unicode from nose.inspector import inspect_traceback class FailureDetail(Plugin): @@ -38,10 +39,11 @@ class FailureDetail(Plugin): """Add detail from traceback inspection to error message of a failure. """ ec, ev, tb = err - tbinfo, str_ev = None, str(ev) + tbinfo, str_ev = None, exc_to_unicode(ev) + if tb: - tbinfo = inspect_traceback(tb) - str_ev = '\n'.join([str(ev), tbinfo]) + tbinfo = force_unicode(inspect_traceback(tb)) + str_ev = '\n'.join([str_ev, tbinfo]) test.tbinfo = tbinfo return (ec, str_ev, tb) |