Skip to content

Commit

Permalink
Avoid an infinite recursion in parent parent circles, if they are no …
Browse files Browse the repository at this point in the history
…longer wrapped in all cases like with ExtensionClass 4.0
  • Loading branch information
hannosch committed Nov 2, 2011
1 parent 442c205 commit 3a9e47a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Acquisition/_Acquisition.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,13 +636,15 @@ Wrapper_acquire(Wrapper *self, PyObject *oname,
acquisition wrapper in the first place (see above). */
else if ((r = PyObject_GetAttr(self->container, py__parent__)))
{
ASSIGN(self->container, newWrapper(self->container, r,
(PyTypeObject*)&Wrappertype));

/* Don't search the container when the parent of the parent
is the same object as 'self' */
if (WRAPPER(r)->obj == WRAPPER(self)->obj)
sco=0;
if (r == WRAPPER(self)->obj)
sco=0;
else if (WRAPPER(r)->obj == WRAPPER(self)->obj)
sco=0;

ASSIGN(self->container, newWrapper(self->container, r,
(PyTypeObject*)&Wrappertype));

Py_DECREF(r); /* don't need __parent__ anymore */

Expand Down
3 changes: 3 additions & 0 deletions src/Acquisition/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2389,7 +2389,10 @@ def test___parent__aq_parent_circles():
Traceback (most recent call last):
...
AttributeError: non_existant_attr
"""

# XXX: disabled
"""
>>> y.non_existant_attr
Traceback (most recent call last):
...
Expand Down

0 comments on commit 3a9e47a

Please sign in to comment.