Python pickle crash when trying to return default value in __getattr__
I have a dictionary like class that I use to store some values as attributes. I recently added some logic( __getattr__ ) to return None if an attribute doesn't exist. As soon as I did this pickle crashed, and I wanted some insight into why? Test Code: import cPickle class DictionaryLike(object): def __init__(self, **kwargs): self.__dict__.update(kwargs) def __iter__(self): return iter(self.__dict__) def __getitem__(self, key): if(self.__dict__.has_key(key)): return self.__dict__[key] else: return None ''' This is the culprit...''' def __getattr__(self, key): print 'Retreiving Value ' , key