From ca8c73cc158c5f29670d7b422582b253d41530ba Mon Sep 17 00:00:00 2001 From: lagos Date: Fri, 26 Oct 2012 20:10:54 -0700 Subject: [PATCH] Changes the way command sets are duplicated to correctly copy over attributes. --- src/commands/cmdset.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/commands/cmdset.py b/src/commands/cmdset.py index 9e52f41460..8eaf2ad452 100644 --- a/src/commands/cmdset.py +++ b/src/commands/cmdset.py @@ -203,7 +203,14 @@ class CmdSet(object): (no actual commands are copied over) """ cmdset = CmdSet() - cmdset.__dict__.update(dict((key, val) for key, val in self.__dict__.items() if key in self.to_duplicate)) + # This is the commented out old behavior for duplication. This would fail to + # copy over attributes defined as class rather than object members. + #cmdset.__dict__.update(dict((key, val) for key, val in self.__dict__.items() if key in self.to_duplicate)) + for key in self.to_duplicate: + try: + setattr(cmdset, key, getattr(self, key)) + except AttributeError: + pass cmdset.key_mergetypes = self.key_mergetypes.copy() #copy.deepcopy(self.key_mergetypes) return cmdset