def _diff_text(left, right, verbose=<NUM_LIT:0>):
from difflib import ndiff<EOL>explanation = []<EOL>def escape_for_readable_diff(binary_text):<EOL><INDENT>"""<STR_LIT>"""<EOL>r = six.text_type(repr(binary_text)[<NUM_LIT:1>:-<NUM_LIT:1>])<EOL>r = r.replace(r"<STR_LIT:\n>", "<STR_LIT:\n>")<EOL>r = r.replace(r"<STR_LIT:\r>", "<STR_LIT:\r>")<EOL>return r<EOL><DEDENT>if isinstance(left, bytes):<EOL><INDENT>left = escape_for_readable_diff(left)<EOL><DEDENT>if isinstance(right, bytes):<EOL><INDENT>right = escape_for_readable_diff(right)<EOL><DEDENT>if verbose < <NUM_LIT:1>:<EOL><INDENT>i = <NUM_LIT:0>  <EOL>for i in range(min(len(left), len(right))):<EOL><INDENT>if left[i] != right[i]:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if i > <NUM_LIT>:<EOL><INDENT>i -= <NUM_LIT:10>  <EOL>explanation = [<EOL>u"<STR_LIT>" % i<EOL>]<EOL>left = left[i:]<EOL>right = right[i:]<EOL><DEDENT>if len(left) == len(right):<EOL><INDENT>for i in range(len(left)):<EOL><INDENT>if left[-i] != right[-i]:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if i > <NUM_LIT>:<EOL><INDENT>i -= <NUM_LIT:10>  <EOL>explanation += [<EOL>u"<STR_LIT>"<EOL>u"<STR_LIT>".format(i)<EOL>]<EOL>left = left[:-i]<EOL>right = right[:-i]<EOL><DEDENT><DEDENT><DEDENT>keepends = True<EOL>if left.isspace() or right.isspace():<EOL><INDENT>left = repr(str(left))<EOL>right = repr(str(right))<EOL>explanation += [u"<STR_LIT>"]<EOL><DEDENT>explanation += [<EOL>line.strip("<STR_LIT:\n>")<EOL>for line in ndiff(left.splitlines(keepends), right.splitlines(keepends))<EOL>]<EOL>return explanation<EOL>
Return the explanation for the diff between text or bytes.

    Unless --verbose is used this will skip leading and trailing
    characters which are identical to keep the diff minimal.

    If the input are bytes they will be safely converted to text.