[Checkins] [zopefoundation/persistent] 4fefda: py/deactivate vs slots: A slot variable could not ...

GitHub noreply at github.com
Tue Nov 29 20:02:36 CET 2016


  Branch: refs/heads/master
  Home:   https://github.com/zopefoundation/persistent
  Commit: 4fefda924c95a9f7f1d06be3b1b84d57c0dec91b
      https://github.com/zopefoundation/persistent/commit/4fefda924c95a9f7f1d06be3b1b84d57c0dec91b
  Author: Kirill Smelkov <kirr at nexedi.com>
  Date:   2016-11-29 (Tue, 29 Nov 2016)

  Changed paths:
    M persistent/persistence.py
    M persistent/tests/test_persistence.py

  Log Message:
  -----------
  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();


  Commit: eda70ac9d0c0f52aea64d2c40f67cd3afd78ad30
      https://github.com/zopefoundation/persistent/commit/eda70ac9d0c0f52aea64d2c40f67cd3afd78ad30
  Author: Jim Fulton <jim at jimfulton.info>
  Date:   2016-11-29 (Tue, 29 Nov 2016)

  Changed paths:
    M persistent/persistence.py
    M persistent/tests/test_persistence.py

  Log Message:
  -----------
  Merge pull request #48 from navytux/slots-delfixup

py/deactivate vs slots: A slot variable could not be initialized at all


Compare: https://github.com/zopefoundation/persistent/compare/c2327db5d49a...eda70ac9d0c0


More information about the checkins mailing list