A possible bug spotted while reviewing the code

Issue #32 closed
Paul Moore
created an issue

I was looking at the Alea code while trying to work out how to solve a particular issue I am working on, and I noticed a suspicious piece of code. I haven't created any sort of test for it (mainly because I'm still using 2.1.2 for my actual problem) but I thought it might be worth raising.

In alea.py line 225 (function times):

        (n2,r) = divmod(n,2)
        alea2 = self.times(n2)

Should that recursive call not be self.times(n2, op)?

Comments (6)

  1. Pierre Denis repo owner

    Yes Paul, you're completely right!

    I see that this bug was introduced in Lea 2.2.0-beta.4, while correcting issue #28. As you noticed, times method is wrong indeed if the operator is not the addition and n > 3.

    Congratulations for your attentiveness and thank you for reporting! I correct this today and distribute Lea 2.2.0-beta.7 on PyPI. Lea definitely needs a formal test suite (see #6) ; it's not done yet by lack of time.

  2. Log in to comment