diff --git a/CHANGELOG b/CHANGELOG index 2f373122b..7f1232366 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,10 +2,11 @@ Changes between 1.2.1 and 1.2.2 (release pending) ================================================== - new mechanism to allow plugins to register new hooks +- fixes for handling of unicode exception values - added links to the new capturelog and coverage plugins - (issue87) fix unboundlocal error in assertionold code - (issue86) improve documentation for looponfailing -- fix jython/win32 issues +- fixes for making jython/win32 work more properly - ship distribute_setup.py version 0.6.10 diff --git a/py/_code/code.py b/py/_code/code.py index ee054fc2e..7cfec853b 100644 --- a/py/_code/code.py +++ b/py/_code/code.py @@ -581,7 +581,10 @@ class TerminalRepr: def __str__(self): tw = py.io.TerminalWriter(stringio=True) self.toterminal(tw) - return tw.stringio.getvalue().strip() + s = tw.stringio.getvalue().strip() + if sys.version_info[0] < 3: + s = s.encode('utf-8') + return s def __repr__(self): return "<%s instance at %0x>" %(self.__class__, id(self)) diff --git a/testing/code/test_code.py b/testing/code/test_code.py index f9f478aa9..583fc7852 100644 --- a/testing/code/test_code.py +++ b/testing/code/test_code.py @@ -192,3 +192,10 @@ def test_builtin_patch_unpatch(monkeypatch): assert cpy_builtin.AssertionError is Sub assert cpy_builtin.compile == mycompile + +def test_unicode_handling(testdir): + value = py.builtin._totext('\xc4\x85\xc4\x87\n', 'utf-8').encode('utf8') + def f(): + raise Exception(value) + excinfo = py.test.raises(Exception, f) + s = str(excinfo)