Update PTRelationSet._add and PTRelationSet._discard to not try to
authorEvan Broder <broder@mit.edu>
Mon, 23 Nov 2009 04:05:42 +0000 (23:05 -0500)
committerEvan Broder <broder@mit.edu>
Mon, 23 Nov 2009 04:11:52 +0000 (23:11 -0500)
mutate the membership set if it hasn't been loaded yet.

Signed-off-by: Evan Broder <broder@mit.edu>

afs/pts.py

index 9c44f3a..4d3e17c 100644 (file)
@@ -45,7 +45,8 @@ class PTRelationSet(collections.MutableSet):
         Args:
             elt: The element to add.
         """
-        self._set.add(self._ent._pts.getEntry(elt))
+        if hasattr(self, '_set'):
+            self._set.add(self._ent._pts.getEntry(elt))
 
     def _discard(self, elt):
         """Remove a PTEntry to this instance's internal representation.
@@ -57,7 +58,8 @@ class PTRelationSet(collections.MutableSet):
         Args:
             elt: The element to discard.
         """
-        self._set.discard(self._ent._pts.getEntry(elt))
+        if hasattr(self, '_set'):
+            self._set.discard(self._ent._pts.getEntry(elt))
 
     def __len__(self):
         """Count the members/groups in this set.