[Spambayes] Corpus.Message.__getattr__ can't be correct can it?

Richie Hindle richie at entrian.com
Fri Jan 17 18:50:54 EST 2003

Hi Skip,

> In Corpus.Message, __getattr__ is defined as
>     def __getattr__(self, attributeName):
>         '''On-demand loading of the message text.'''
>         if attributeName in ('hdrtxt', 'payload'):
>             self.load()
>         return getattr(self, attributeName)
> This has to be an infloop, right?

It should probably be:

    return self.__dict__[attributeName]

so that it raises an exception when something goes wrong.  This is probably
related to

The suggested fix in the bug report looks needlessly destructive to me -
I'd use something like (untested)

        if bmatch:
            self.payload = bmatch.group(2)
            self.hdrtxt = sub[:bmatch.start(2)]
            self.payload = sub
            self.hdrtxt = ""

Skip, since you're having trouble with this and I can't reproduce it, could
you try the above edit?  Tim S if you're listening, any better ideas?

Richie Hindle
richie at entrian.com

More information about the Spambayes mailing list