Fix decoding issue while formatting SyntaxErrors during collection

This happens only in Python 2, as in Python 3 we receive
the "badline" in the exception is already properly encoded

Fix #578
This commit is contained in:
Bruno Oliveira
2016-03-05 16:58:44 -03:00
parent 3884398055
commit d8403d793f
4 changed files with 42 additions and 1 deletions

View File

@@ -93,6 +93,17 @@ def test_unicode_handling():
if sys.version_info[0] < 3:
unicode(excinfo)
@pytest.mark.skipif(sys.version_info[0] >= 3, reason='python 2 only issue')
def test_unicode_handling_syntax_error():
value = py.builtin._totext('\xc4\x85\xc4\x87\n', 'utf-8').encode('utf8')
def f():
raise SyntaxError('invalid syntax', (None, 1, 3, value))
excinfo = pytest.raises(Exception, f)
str(excinfo)
if sys.version_info[0] < 3:
unicode(excinfo)
def test_code_getargs():
def f1(x):
pass