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

Just van Rossum just at letterror.com
Fri Jan 17 20:29:15 EST 2003


Richie Hindle wrote:

> > 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. [ ... ]

Neither makes sense (unless I'm missing some magic context): __getattr__
is only called if the attr isn't found the normal way, which means it's
for sure not in self.__dict__.

Just



More information about the Spambayes mailing list