py/deactivate vs slots: A slot variable could not be initialized at all
fe2219f4 (On deactivate release in-slots objects too) started to release objects from slotted variables but was not careful enough while doing so: we have to be careful while deleting as for unset variables it will raise AttributeError: class C(object): __slots__ = ['aaa', 'unset'] def __init__(self, aaa): self.aaa = 1 c = C(111) del c.aaa del c.unset Traceback (most recent call last): File "y.py", line 9, in <module> del c.unset AttributeError: unset Caught by preparing fix for https://github.com/zopefoundation/persistent/pull/44#issuecomment-256768600 C version already have this protection in the original fe2219f4 patch: + if (PyObject_GenericSetAttr((PyObject *)self, name, NULL) < 0) + /* delattr of non-set slot will raise AttributeError - we + * simply ignore. */ + PyErr_Clear();
Showing
Please register or sign in to comment