From 2950a115fb106ae73b87f87dc4865156d9311f8e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 29 Aug 2012 14:54:33 -0400 Subject: [PATCH] bugdir: add `update` argument to BugDir.append(). This avoids a deepcopy error where the BugDir tries to update before the Bug has had it's uuid assigned: Traceback (most recent call last): ... File ".../libbe/command/merge.py", line 168, in _run newCommTree = copy.deepcopy(bugB.comment_root) File "/usr/lib64/python2.7/copy.py", line 190, in deepcopy y = _reconstruct(x, rv, 1, memo) ... File "/usr/lib64/python2.7/copy.py", line 352, in _reconstruct y.append(item) File ".../libbe/bugdir.py", line 263, in append self._bug_map_gen() File ".../libbe/bugdir.py", line 152, in _bug_map_gen map[bug.uuid] = bug AttributeError: 'Bug' object has no attribute 'uuid' --- libbe/bugdir.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libbe/bugdir.py b/libbe/bugdir.py index 0399a82..a3a388c 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -255,14 +255,16 @@ class BugDir (list, settings_object.SavedSettingsObject): def new_bug(self, summary=None, _uuid=None): bg = bug.Bug(bugdir=self, uuid=_uuid, summary=summary, from_storage=False) - self.append(bg) + self.append(bg, update=True) return bg - def append(self, bug): + def append(self, bug, update=False): super(BugDir, self).append(bug) - self._bug_map_gen() - if hasattr(self, '_uuids_cache') and not bug.uuid in self._uuids_cache: - self._uuids_cache.add(bug.uuid) + if update: + self._bug_map_gen() + if (hasattr(self, '_uuids_cache') and + not bug.uuid in self._uuids_cache): + self._uuids_cache.add(bug.uuid) def remove_bug(self, bug): if hasattr(self, '_uuids_cache') and bug.uuid in self._uuids_cache: @@ -443,7 +445,7 @@ class BugDir (list, settings_object.SavedSettingsObject): bg = bug.Bug(bugdir=self) bg.from_xml( child, preserve_uuids=preserve_uuids, verbose=verbose) - self.append(bg) + self.append(bg, update=True) continue elif child.tag in tags: if child.text == None or len(child.text) == 0: -- 2.26.2