Description

When doing a diff on a page, I received a division by zero error.

Steps to reproduce

I'll try and get a raw file of this Wiki data.

Diff for "Proposed Build System/Buildroot Toolchain"

Differences between revisions 9 and 10
--> -->
 
 
ZeroDivisionErrorfloat division Please include this information in your bug reports!:
Python Python 2.2.3: /bin/python
Linux weldon 2.4.21-15.EL #1 Sun May 16 02:07:24 EDT 2004 i686
MoinMoin Release 1.3.1 [Revision patch-434]
Tue Jul 5 16:21:59 2005

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

 /nobackup/local/lib/python2.2/site-packages/MoinMoin/request.py in run(self=<MoinMoin.request.RequestCGI instance>)
  822             else:
  823                 try:
  824                     cgitb.Hook(file=self).handle(saved_exc)
  825                     # was: cgitb.handler()
  826                 except:
cgitb = <module 'MoinMoin.support.cgitb' from '/nobackup...hon2.2/site-packages/MoinMoin/support/cgitb.pyc'>, cgitb.Hook = <class MoinMoin.support.cgitb.Hook>, file undefined, self = <MoinMoin.request.RequestCGI instance>, ).handle undefined, saved_exc = (<class exceptions.ZeroDivisionError>, <exceptions.ZeroDivisionError instance>, <traceback object>)

 /nobackup/local/lib/python2.2/site-packages/MoinMoin/wikiaction.py in do_diff(pagename=u'Proposed Build System/Buildroot Toolchain', request=<MoinMoin.request.RequestCGI instance>)
  162     if request.user.show_fancy_diff:
  163         from MoinMoin.util.diff import diff
  164         request.write(diff(request, oldpage.get_raw_body(), newpage.get_raw_body()))
  165         newpage.send_page(request, count_hit=0, content_only=1, content_id="content-below-diff")
  166     else:
request = <MoinMoin.request.RequestCGI instance>, request.write = <bound method RequestCGI.write of <MoinMoin.request.RequestCGI instance>>, diff = <function diff>, oldpage = <MoinMoin.Page.Page instance>, oldpage.get_raw_body = <bound method Page.get_raw_body of <MoinMoin.Page.Page instance>>, newpage = <MoinMoin.Page.Page instance>, newpage.get_raw_body = <bound method Page.get_raw_body of <MoinMoin.Page.Page instance>>

 /nobackup/local/lib/python2.2/site-packages/MoinMoin/util/diff.py in diff(request=<MoinMoin.request.RequestCGI instance>, old=u'This is a subtopic under ["Proposed Build System...n place overview].\n----\nCategoryDeveloperRecipie\n', new=u'This is a subtopic under ["Proposed Build System...n place overview].\n----\nCategoryDeveloperRecipie\n')
   94         charmatch = charobj.get_matching_blocks()
   95         
   96         if charobj.ratio() < 0.5:
   97             # Insufficient similarity.
   98             if leftpane:
charobj = <difflib.SequenceMatcher instance>, charobj.ratio = <bound method SequenceMatcher.ratio of <difflib.SequenceMatcher instance>>

 /usr/lib/python2.2/difflib.py in ratio(self=<difflib.SequenceMatcher instance>)
  526         matches = reduce(lambda sum, triple: sum + triple[-1],
  527                          self.get_matching_blocks(), 0)
  528         return 2.0 * matches / (len(self.a) + len(self.b))
  529 
  530     def quick_ratio(self):

Note: the size is very, very close. I think there's an off-by-one bug in the code that leads to this point (these are the two version I was diffing):

10      05.07.2005 13:08:30     5583            stjeanma                 view raw print
9       05.07.2005 13:07:32     5581            stjeanma                 view raw print revert

Example

This occurs on an internal Wiki we have. It cannot be connected to from the Internet.

Details

1.3.1 RP-434

RHEL Linux 2.4.21-15.EL

Python 2.2.3

Server Apache

MoinMoin configured as a module.

Workaround

Discussion

This is already known and fixed. See MoinMoinBugs/DiffCausesZeroDivisionError.

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/DiffDivisionByZero (last edited 2007-10-29 19:19:42 by localhost)