Log message for revision 76140:
  First attempt to fix 'Acquisition problem' when encountering cyclic 
hierarchies via __parent__ pointers. [hannosch, nouri]
  

Changed:
  U   
Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/_Acquisition.c
  U   Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/tests.py

-=-
Modified: 
Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/_Acquisition.c
===================================================================
--- 
Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/_Acquisition.c  
    2007-06-01 20:55:13 UTC (rev 76139)
+++ 
Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/_Acquisition.c  
    2007-06-01 22:49:26 UTC (rev 76140)
@@ -574,7 +574,16 @@
         {
           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);

Modified: 
Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/tests.py
===================================================================
--- Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/tests.py    
2007-06-01 20:55:13 UTC (rev 76139)
+++ Zope/branches/philikon-aq-and-__parent__/lib/python/Acquisition/tests.py    
2007-06-01 22:49:26 UTC (rev 76140)
@@ -2010,23 +2010,20 @@
       ...     hello = 'world2'
 
       >>> x = Expl()
-      >>> y = Expl2().__of__(x)
+      >>> y = Expl2()
       >>> x.__parent__ = y
+      >>> y.__parent__ = x
 
-      >>> x.__parent__.aq_base is y.aq_base
-      True
-
       >>> 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

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to