[issue21635] difflib.SequenceMatcher stores matching blocks as tuples, not Match named tuples

Raymond Hettinger report at bugs.python.org
Sat Jun 21 06:43:09 CEST 2014


Raymond Hettinger added the comment:

> What behavior both looks wrong and gets improved by the change?

The incorrect behavior is that matching_blocks is incorrectly cached so that calls to get_matching_blocks() returns an answer without the named tuple (in contravention of the documented behavior):

>>> s = SequenceMatcher(None, "abxcd", "abcd")
>>> s.get_matching_blocks()
[Match(a=0, b=0, size=2), Match(a=3, b=2, size=2), Match(a=5, b=4, size=0)]
>>> s.get_matching_blocks()
[(0, 0, 2), (3, 2, 2), (5, 4, 0)]
>>> s.get_matching_blocks()
[(0, 0, 2), (3, 2, 2), (5, 4, 0)]

----------
priority: normal -> high
stage: test needed -> needs patch
versions: +Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21635>
_______________________________________


More information about the Python-bugs-list mailing list