def _saferepr(obj):
r = saferepr(obj)<EOL>if isinstance(r, bytes):<EOL><INDENT>r = u"<STR_LIT>".join(<EOL>u"<STR_LIT>".format(ord(c)) if c not in string.printable else c.decode()<EOL>for c in r<EOL>)<EOL><DEDENT>return r.replace(u"<STR_LIT:\n>", u"<STR_LIT>")<EOL>
Get a safe repr of an object for assertion error messages.

    The assertion formatting (util.format_explanation()) requires
    newlines to be escaped since they are a special character for it.
    Normally assertion.util.format_explanation() does this but for a
    custom repr it is possible to contain one of the special escape
    sequences, especially '\n{' and '\n}' are likely to be present in
    JSON reprs.