Skip to content

Commit

Permalink
First attempt to fix 'Acquisition problem' when encountering cyclic h…
Browse files Browse the repository at this point in the history
…ierarchies via __parent__ pointers. [hannosch, nouri]
  • Loading branch information
hannosch committed Jun 1, 2007
1 parent e2164f2 commit 3daf326
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
9 changes: 9 additions & 0 deletions _Acquisition.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,16 @@ Wrapper_acquire(Wrapper *self, PyObject *oname,
{
ASSIGN(self->container, newWrapper(self->container, r,
(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 */

r=Wrapper_findattr((Wrapper*)self->container,
oname, filter, extra, orig, sob, sco, explicit,
containment);
Expand Down
15 changes: 6 additions & 9 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2010,23 +2010,20 @@ def test___parent__aq_parent_cycles():
... hello = 'world2'
>>> x = Expl()
>>> y = Expl2().__of__(x)
>>> y = Expl2()
>>> x.__parent__ = y
>>> x.__parent__.aq_base is y.aq_base
True
>>> y.__parent__ = x
>>> x.__parent__.__parent__ is x
True
>>> Acquisition.aq_get(x, 'hello')
'world'
XXX This causes a segmentation fault, as some tests in Products.Five do
as well
>>> Acquisition.aq_get(x, 'hello2')
>>> Acquisition.aq_get(x, 'hello2') #doctest:+ELLIPSIS
Traceback (most recent call last):
...
AttributeError: hello2
"""

import unittest
Expand Down

0 comments on commit 3daf326

Please sign in to comment.