Commit 3daf326d authored by Hanno Schlichting's avatar Hanno Schlichting

First attempt to fix 'Acquisition problem' when encountering cyclic...

First attempt to fix 'Acquisition problem' when encountering cyclic hierarchies via __parent__ pointers. [hannosch, nouri]
parent e2164f2b
...@@ -574,7 +574,16 @@ Wrapper_acquire(Wrapper *self, PyObject *oname, ...@@ -574,7 +574,16 @@ Wrapper_acquire(Wrapper *self, PyObject *oname,
{ {
ASSIGN(self->container, newWrapper(self->container, r, ASSIGN(self->container, newWrapper(self->container, r,
(PyTypeObject*)&Wrappertype)); (PyTypeObject*)&Wrappertype));
/* Don't try to get any attributes when the parent object of the
parent object is the same as the object itself. */
if (WRAPPER(r)->obj==WRAPPER(self)->obj) {
Py_DECREF(r);
PyErr_SetObject(PyExc_AttributeError,oname);
return NULL;
}
Py_DECREF(r); /* don't need __parent__ anymore */ Py_DECREF(r); /* don't need __parent__ anymore */
r=Wrapper_findattr((Wrapper*)self->container, r=Wrapper_findattr((Wrapper*)self->container,
oname, filter, extra, orig, sob, sco, explicit, oname, filter, extra, orig, sob, sco, explicit,
containment); containment);
......
...@@ -2010,11 +2010,9 @@ def test___parent__aq_parent_cycles(): ...@@ -2010,11 +2010,9 @@ def test___parent__aq_parent_cycles():
... hello = 'world2' ... hello = 'world2'
>>> x = Expl() >>> x = Expl()
>>> y = Expl2().__of__(x) >>> y = Expl2()
>>> x.__parent__ = y >>> x.__parent__ = y
>>> y.__parent__ = x
>>> x.__parent__.aq_base is y.aq_base
True
>>> x.__parent__.__parent__ is x >>> x.__parent__.__parent__ is x
True True
...@@ -2022,11 +2020,10 @@ def test___parent__aq_parent_cycles(): ...@@ -2022,11 +2020,10 @@ def test___parent__aq_parent_cycles():
>>> Acquisition.aq_get(x, 'hello') >>> Acquisition.aq_get(x, 'hello')
'world' 'world'
XXX This causes a segmentation fault, as some tests in Products.Five do >>> Acquisition.aq_get(x, 'hello2') #doctest:+ELLIPSIS
as well Traceback (most recent call last):
>>> Acquisition.aq_get(x, 'hello2') ...
AttributeError: hello2
""" """
import unittest import unittest
......
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