fall back to repr() when we can't actually decode a failure message, fixes #14

This commit is contained in:
Tim Cuthbertson 2012-06-04 22:08:54 +10:00
parent 8ba7bb63ae
commit a3ce77ac88
3 changed files with 19 additions and 2 deletions

View File

@ -8,6 +8,9 @@ rednose-local.xml: rednose.xml
0launch http://gfxmonk.net/dist/0install/0local.xml rednose.xml rednose-local.xml
test: rednose-local.xml
0launch http://0install.net/2008/interfaces/0test.xml rednose-local.xml http://repo.roscidus.com/python/python 2.7.2-7 3.2.2-0
0launch http://0install.net/2008/interfaces/0test.xml \
rednose-local.xml \
http://repo.roscidus.com/python/python \
2.7.3-6 3.2.3-5
.PHONY: 0 pypi

7
encoding_test.py Normal file
View File

@ -0,0 +1,7 @@
# vim: fileencoding=utf-8:
#NOTE: this file does *not* import unicode_literals,
# so the assertion message is actually just utf-8 bytes
def test():
assert False, "ä"

View File

@ -44,7 +44,14 @@ skip = 'skipped'
line_length = 77
PY3 = sys.version_info[0] >= 3
to_unicode = str if PY3 else unicode
if PY3:
to_unicode = str
else:
def to_unicode(s):
try:
return unicode(s)
except UnicodeDecodeError:
return unicode(repr(str(s)))
BLACKLISTED_WRITERS = [
'nose[\\/]result\\.pyc?$',