def get_diff_for(doc, old_rev, new_rev):
        fromfile = u'[%s] %s #%s' % (doc.locale, doc.title, old_rev.id)
        tofile = u'[%s] %s #%s' % (doc.locale, doc.title, new_rev.id)
        # difflib expects these to be bytes, not unicode
        fromfile = fromfile.encode('utf8')
        tofile = tofile.encode('utf8')

        # Get diff
        diff_parts = difflib.unified_diff(
            old_rev.content.splitlines(1),
            new_rev.content.splitlines(1),
            fromfile=fromfile, tofile=tofile)

        # Join diff parts
        # XXX this is super goofy
        acc = u''
        for d in diff_parts:
            if isinstance(d, unicode):
                acc = acc + d
            else:
                acc = acc + d.decode('utf8')

        # Clean output
        return clean(acc, ALLOWED_TAGS, ALLOWED_ATTRIBUTES)
dataset/ETHPy150Open mozilla/kitsune/kitsune/wiki/events.py/get_diff_for/original