Skip to content

difflib.SequenceMatcher.find_longest_match return wrong result #134116

Closed
@unisgn

Description

@unisgn

Bug report

Bug description:

Python 3.13.3 (main, Apr 9 2025, 07:44:25) [GCC 14.2.1 20250207]

import difflib
s1='TZiSLutKO5xRiAkkw1ZGkpZsq4'
s2='hTkmKeyY0WYoEqn7xD6jDRwRU4quqozyh8WFwkYY82h9wVv93iUzijw4Q8JYh4l496RD20dsTmy1T0Tl5D1sLRetaW2PP75f9fLeSCllRmISdDFLb3QazkubtOAjZ95a5Ril7NdVIX8hJWlJgwmhd7FGlO5aQQQbLeQcSEFqmiDZOnBWoAisj9YeKHiihm2QzAsdZAN78CO8tXEHfKjCOoZWQo513tEJ4b26BRItK'
m = difflib.SequenceMatcher(None, s1, s2).find_longest_match(ahi=len(s1),bhi=len(s2))
assert s1.find('tK') == 6
assert len(s2) == 233
assert s2.find('tK') == 231
assert m == difflib.Match(3,100,1)

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions