[Python-bugs-list] [ python-Bugs-763023 ] difflib.py: line 528 in ratio() zero division not caught
SourceForge.net
noreply@sourceforge.net
Mon, 30 Jun 2003 08:19:59 -0700
Bugs item #763023, was opened at 2003-06-30 02:24
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=763023&group_id=5470
Category: Python Library
Group: Python 2.2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Matthias Klose (doko)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: difflib.py: line 528 in ratio() zero division not caught
Initial Comment:
2.2.3 and 2.3b1:
>>> from difflib import *
>>> s = SequenceMatcher(None, [], [])
>>> s.ratio()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/difflib.py", line 528, in
ratio
return 2.0 * matches / (len(self.a) + len(self.b))
ZeroDivisionError: float division
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-06-30 11:19
Message:
Logged In: YES
user_id=33168
This affects 2.3 as well (line 614). The return line can be
wrapped with try/except ZeroDivisionError. Raymond, should
0.0 be returned in this case? Should something else be done?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=763023&group_id=5470