#877 - reencoding causes typeerrors on python2
This commit is contained in:
parent
49c99a41ea
commit
7658f60146
|
@ -130,13 +130,15 @@ def assertrepr_compare(config, op, left, right):
|
||||||
left_repr = py.io.saferepr(left, maxsize=int(width/2))
|
left_repr = py.io.saferepr(left, maxsize=int(width/2))
|
||||||
right_repr = py.io.saferepr(right, maxsize=width-len(left_repr))
|
right_repr = py.io.saferepr(right, maxsize=width-len(left_repr))
|
||||||
|
|
||||||
# the reencoding is needed for python2 repr
|
# the re-encoding is needed for python2 repr
|
||||||
# with non-ascii characters (see isssue 877)
|
# with non-ascii characters (see issue 877)
|
||||||
summary = u('%s %s %s') % (
|
def ecu(s):
|
||||||
u(left_repr, 'utf-8', 'replace'),
|
try:
|
||||||
op,
|
return u(s, 'utf-8', 'replace')
|
||||||
u(right_repr, 'utf-8', 'replace'),
|
except TypeError:
|
||||||
)
|
return s
|
||||||
|
|
||||||
|
summary = u('%s %s %s') % (ecu(left_repr), op, ecu(right_repr))
|
||||||
|
|
||||||
issequence = lambda x: (isinstance(x, (list, tuple, Sequence))
|
issequence = lambda x: (isinstance(x, (list, tuple, Sequence))
|
||||||
and not isinstance(x, basestring))
|
and not isinstance(x, basestring))
|
||||||
|
|
Loading…
Reference in New Issue