Skip to content

Commit

Permalink
simplyfy ascii escaping by using backslashreplace error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Aug 30, 2017
1 parent 488bbd2 commit bf7d525
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions _pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def isclass(object):


if _PY3:
import codecs
imap = map
izip = zip
STRING_TYPES = bytes, str
Expand All @@ -146,13 +145,7 @@ def _ascii_escaped(val):
"""
if isinstance(val, bytes):
if val:
# source: http://goo.gl/bGsnwC
encoded_bytes, _ = codecs.escape_encode(val)
return encoded_bytes.decode('ascii')
else:
# empty bytes crashes codecs.escape_encode (#1087)
return ''
return val.decode('ascii', 'backslashreplace')
else:
return val.encode('unicode_escape').decode('ascii')
else:
Expand Down

0 comments on commit bf7d525

Please sign in to comment.