[Moin-devel] [ moin-Bugs-1042475 ] ZeroDivisionError on diff

SourceForge.net noreply at sourceforge.net
Sun Oct 17 15:27:04 EDT 2004


Bugs item #1042475, was opened at 2004-10-07 21:23
Message generated for change (Comment added) made by thomaswaldmann
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108482&aid=1042475&group_id=8482

Category: None
Group: None
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Michael P. Soulier (msoulier)
Assigned to: Nobody/Anonymous (nobody)
Summary: ZeroDivisionError on diff

Initial Comment:
Someone just changed a page on my wiki, and now a diff
crashes with a ZeroDivisionError. 

Python Python 2.2.2: /usr/bin/python2
Linux rabbit 2.4.20-18.7 #1 Thu May 29 06:51:53 EDT
2003 i686
MoinMoin Release 1.2.3 [Revision 1.186]
Thu Oct 7 15:18:11 2004

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

 /usr/local/lib/python2.2/site-packages/MoinMoin/request.py
in run(self=<MoinMoin.request.RequestCGI instance>)
  454             else:
  455                 try:
  456                    
cgitb.Hook(file=self).handle(saved_exc)
  457                     # was: cgitb.handler()
  458                 except:
cgitb = <module 'MoinMoin.support.cgitb' from
'/usr/loca...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>)

 /usr/local/lib/python2.2/site-packages/MoinMoin/wikiaction.py
in do_diff(pagename='OpenLetterOnPython',
request=<MoinMoin.request.RequestCGI instance>)
  294     if request.user.show_fancy_diff:
  295         from MoinMoin.util.diff import diff
  296         request.write(diff(request,
oldpage.get_raw_body(), newpage.get_raw_body()))
  297         newpage.send_page(request, count_hit=0,
content_only=1, content_id="content-under-diff")
  298     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>>

 /usr/local/lib/python2.2/site-packages/MoinMoin/util/diff.py
in diff(request=<MoinMoin.request.RequestCGI instance>,
old="= An Open Letter on Python =\n\n== What Is This?
=...s/cat_python.html#003382 Toward Python's
future]\n", new="= An Open Letter on Python =\n\n==
What Is This? =...s/cat_python.html#003382 Toward
Python's future]\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):
matches = 0, len undefined, self =
<difflib.SequenceMatcher instance>, self.a = '', self.b
= ''

ZeroDivisionError: float division
      __doc__ = 'Second argument to a division or
modulo operation was zero.'
      __getitem__ = <bound method
ZeroDivisionError.__getitem__ of
<exceptions.ZeroDivisionError instance>>
      __init__ = <bound method
ZeroDivisionError.__init__ of
<exceptions.ZeroDivisionError instance>>
      __module__ = 'exceptions'
      __str__ = <bound method ZeroDivisionError.__str__
of <exceptions.ZeroDivisionError instance>>
      args = ('float division',)

----------------------------------------------------------------------

>Comment By: Thomas Waldmann (thomaswaldmann)
Date: 2004-10-18 00:26

Message:
Logged In: YES 
user_id=100649

IIRC, this can be easily fixed by using difflib of python 2.2.3.

Or even better, by upgrading to python 2.3.


----------------------------------------------------------------------

Comment By: Michael P. Soulier (msoulier)
Date: 2004-10-07 21:24

Message:
Logged In: YES 
user_id=470843

528         return 2.0 * matches / (len(self.a) + len(self.b))

Looks like self.a and self.b are zero length. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108482&aid=1042475&group_id=8482




More information about the Moin-devel mailing list