From d40cad57e3da1424bbb2a5323004adf1f4fb3677 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 31 May 2009 15:13:32 -0400 Subject: [PATCH] Record.copy(): deal with defined, but unavailable fields. --- pytools/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pytools/__init__.py b/pytools/__init__.py index 5f5a8ef..b372dd2 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -73,7 +73,10 @@ class Record(object): def copy(self, **kwargs): for f in self.__class__.fields: if f not in kwargs: - kwargs[f] = getattr(self, f) + try: + kwargs[f] = getattr(self, f) + except AttributeError: + pass return self.__class__(**kwargs) def __getstate__(self): -- GitLab