def truncate_text(text, limit, killwords=False, end='...'):
    text = text.strip()
    text_length = len(text)

    if text_length < limit:
        return text, limit - text_length

    # Explicitly add "end" in any case, as Jinja can't know we're truncating
    # for real here, even though we might be at the end of a word.
    # FIXME: Behaviour of truncate_text changed with Jinja2 2.8 so this might
    # not make much sense to continue doing our own thing, investigate.
    text = jinja2.filters.do_truncate(text, limit, killwords, end='')
    return text + end, 0
Test for equality
dataset/ETHPy150Open mozilla/addons-server/src/olympia/translations/utils.py/truncate_text--crossover with--dataset/ETHPy150Open PythonProgramming/Beginning-Game-Development-with-Python-and-Pygame/Chapter 10/gameobjects/vector3.py/Vector3.__eq__