[ZODB-Dev] ZODB 3.2.4 strange getattr, hasattr behaviour

Syver Enstad syver at inout.no
Tue Nov 23 07:01:36 EST 2004


Syver Enstad <syver at inout.no> writes:

> I get None when I do getattr on a not existing attribute in a
> Persistent derived class (instead of AttributeError) . This doesn't
> happen all the time but occurs in an upgrade script. hasattr for the
> same attribute also returns True, but it is not in self.__dict__ and
> delattr raises KeyError.
> 
> I will investigate further and I see what I find out. Maybe it is
> something strange in my code which causes this behaviour.

Aargh, fooled by class level default attribute. Thanks for watching me
make a fool of myself :-). Add one more occurence of being fooled due
to python's way of looking up attributes in the instance and then in
the class. Did someone say explicit is better than implicit ;-)





More information about the ZODB-Dev mailing list