From c306a0dc4b0390e377206b82295f4f8f0eff8209 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 9 Jun 2009 03:23:05 -0400 Subject: [PATCH] Small improvements to Record. --- pytools/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pytools/__init__.py b/pytools/__init__.py index 670b07b..c771fcd 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) -- GitLab