Commit eda70ac9 authored by Jim Fulton's avatar Jim Fulton Committed by GitHub

Merge pull request #48 from navytux/slots-delfixup

py/deactivate vs slots: A slot variable could not be initialized at all
parents c2327db5 4fefda92
......@@ -428,7 +428,12 @@ class Persistent(object):
# class does not override __new__ )
if type_.__new__ is Persistent.__new__:
for slotname in Persistent._slotnames(self, _v_exclude=False):
getattr(type_, slotname).__delete__(self)
try:
getattr(type_, slotname).__delete__(self)
except AttributeError:
# AttributeError means slot variable was not initialized at all -
# - we can simply skip its deletion.
pass
# Implementation detail: deactivating/invalidating
# updates the size of the cache (if we have one)
......
......@@ -1321,7 +1321,7 @@ class _Persistent_Base(object):
def test__p_invalidate_from_changed_w_slots(self):
class Derived(self._getTargetClass()):
__slots__ = ('myattr1', 'myattr2')
__slots__ = ('myattr1', 'myattr2', 'unset')
def __init__(self):
self.myattr1 = 'value1'
self.myattr2 = 'value2'
......
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