Skip to content

Commit

Permalink
Remove faulty assertion in PersistentMapping.clear().
Browse files Browse the repository at this point in the history
If there's no jar, we can't be _p_changed.

Fixes #139.
  • Loading branch information
jamadden committed Mar 12, 2020
1 parent ce84010 commit f80c7b7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Expand Up @@ -4,7 +4,9 @@
4.6.2 (unreleased)
------------------

- Nothing changed yet.
- Fix an ``AssertionError`` clearing a non-empty ``PersistentMapping``
that has no connection. See `issue 139
<https://github.com/zopefoundation/persistent/issues/139>`_.


4.6.1 (2020-03-06)
Expand Down
1 change: 0 additions & 1 deletion persistent/mapping.py
Expand Up @@ -101,7 +101,6 @@ def clear(self):
self.__super_clear()
if needs_changed:
self._p_changed = 1
assert self._p_changed

def update(self, *args, **kwargs):
"""
Expand Down
9 changes: 9 additions & 0 deletions persistent/tests/test_mapping.py
Expand Up @@ -273,6 +273,15 @@ def test_clear_empty(self):
pm.clear()
self.assertFalse(pm._p_changed)

def test_clear_no_jar(self):
# https://github.com/zopefoundation/persistent/issues/139
self._makeOne = self._getTargetClass()
self.test_clear_empty()

pm = self._makeOne(a=42)
pm.clear()
self.assertFalse(pm._p_changed)

def test_clear_empty_legacy_container(self):
pm = self._makeOne()
pm.__dict__['_container'] = pm.__dict__.pop('data')
Expand Down

0 comments on commit f80c7b7

Please sign in to comment.