[issue24904] Patch: add timeout to difflib SequenceMatcher ratio() and quick_ratio()

John Taylor report at bugs.python.org
Fri Aug 21 00:18:08 CEST 2015


New submission from John Taylor:

SequenceMatcher in the difflib module contain ratio() and quick_ratio() methods which can take a long time to run with certain input.  One example is two slightly different versions of jquery.min.js.

I have written a patch against python-350b4 that adds a timeout to these methods.  The new functionality also has the capability to "fall through" to the next quickest comparison method should a timeout occur. If a timeout does occur and using a fall through method is not desired, then -1 is returned for the ratio.

I'd like this to be incorporated into Python 3.5.0 if it is not too late.

----------
components: Library (Lib)
files: difflib-diff.patch
keywords: patch
messages: 248919
nosy: jftuga
priority: normal
severity: normal
status: open
title: Patch: add timeout to difflib SequenceMatcher ratio() and quick_ratio()
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file40217/difflib-diff.patch

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


More information about the Python-bugs-list mailing list