Commit aa091e6f authored by Jason Madden's avatar Jason Madden

Pure Python Set objects were also not marking themselves changed on addition....

Pure Python Set objects were also not marking themselves changed on addition. This impacted things like zope.index.topic.filter
parent 332503d8
......@@ -559,6 +559,7 @@ class Set(_BucketBase):
index = self._search(key)
if index < 0:
index = -index - 1
self._p_changed = True
self._keys.insert(index, key)
return True, None
return False, None
......
......@@ -1421,6 +1421,32 @@ class NormalSetTests(Base):
self.assertTrue(t._p_changed)
self.assertEqual(t, t._p_jar.registered)
def testAddingOneSetsChanged(self):
# A bug in the BTree Set Python implementation once caused
# adding an object not to set _p_changed
t = self._makeOne()
# Note that for the property to actually hold, we have to fake a
# _p_jar and _p_oid
t._p_oid = b'\0\0\0\0\0'
class Jar(object):
def __init__(self):
self._cache = self
self.registered = None
def mru(self, arg):
pass
def readCurrent(self, arg):
pass
def register(self, arg):
self.registered = arg
t._p_jar = Jar()
t.add(0)
self.assertTrue(t._p_changed)
self.assertEqual(t, t._p_jar.registered)
# Whether or not doing `t.add(0)` again would result in
# _p_changed being set depends on whether this is a TreeSet or a plain Set
class ExtendedSetTests(NormalSetTests):
......
......@@ -5,7 +5,7 @@
------------------
- Fix _p_changed when removing items from small pure-Python
BTrees/TreeSets. See:
BTrees/TreeSets and when adding to Sets. See:
https://github.com/zopefoundation/BTrees/issues/13
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment