[spambayes-dev] RE: Bug in UserInterface.py

Kenny Pitt kennypitt at hotmail.com
Tue Nov 11 12:18:09 EST 2003

Tim Peters wrote:
> Would someone familiar with UserInterface.py please check in the
> attached patch, or add it to the patch manager if you're unsure about
> it?  Thanks! 

[from attached patch]
diff -r1.32 UserInterface.py
<     sc_re = re.compile("%s:(.*)\n" % \
>     sc_re = re.compile("%s:\s*(\d*\.\d+|\d+\.\d*).*\n" % \

This would probably work if and when the fix for bug #831388 is applied.
However, the current code inserts the probability in the
X-Spambayes-Spam-Probability: header using str(prob), which can go into
the "e" exponent notation for very small probs.  If this happens, the
patched regex will fail to properly identify the probability.  The regex
can be modified as follows if you want to account for this possibility:

sc_re = re.compile("%s:\s*((\d*\.\d+|\d+\.\d*)(e[-+]\d+)?).*\n" % \

In addition, I believe that there will always be at least one digit
before the decimal point as the leading zero is always included, so we
should be able to simplify the expression to:

sc_re = re.compile("%s:\s*(\d+\.\d*(e[-+]\d+)?).*\n" % \

Kenny Pitt

More information about the spambayes-dev mailing list