diff --git a/pytools/__init__.py b/pytools/__init__.py index 670b07bc6d0f7fbf6d7132ed6978e865922b0063..c771fcd8f0d4c55c538f5d97e5d5c794a2b540be 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -82,7 +82,8 @@ class Record(object): def __getstate__(self): return dict( (key, getattr(self, key)) - for key in self.__class__.fields) + for key in self.__class__.fields + if hasattr(self, key)) def __setstate__(self, valuedict): try: @@ -101,7 +102,8 @@ class Record(object): for fld in self.__class__.fields)) def __eq__(self, other): - return self.__getstate__() == other.__getstate__() + return (self.__class__ == other.__class__ + and self.__getstate__() == other.__getstate__()) def __ne__(self, other): return not self.__eq__(other)