Update of /cvs-repository/Cruft/ExtensionClass/src
In directory cvs.zope.org:/tmp/cvs-serv6895

Modified Files:
      Tag: zc-Zope-2-7-5
        Acquisition.c 
Log Message:
Backported fix fromn trunk.  The simplification of wrappers is not
merely an optimization. It is critical for getting correct wrapper
semantics.


=== Cruft/ExtensionClass/src/Acquisition.c 1.61.4.1 => 1.61.4.1.32.1 ===
--- Cruft/ExtensionClass/src/Acquisition.c:1.61.4.1     Tue Oct 21 08:44:39 2003
+++ Cruft/ExtensionClass/src/Acquisition.c      Tue Mar  7 17:56:25 2006
@@ -138,39 +138,6 @@
 
 /* ---------------------------------------------------------------- */
 
-static PyObject *
-__of__(PyObject *inst, PyObject *parent)
-{
-  PyObject *r, *t;
-
-  UNLESS(r=PyObject_GetAttr(inst, py__of__)) return NULL;
-  UNLESS(t=PyTuple_New(1)) goto err;
-  PyTuple_SET_ITEM(t,0,parent);
-  ASSIGN(r,PyObject_CallObject(r,t));
-  PyTuple_SET_ITEM(t,0,NULL);
-  Py_DECREF(t);
-
-  if (r 
-      && r->ob_refcnt==1
-      && isWrapper(r) 
-      && WRAPPER(r)->container && isWrapper(WRAPPER(r)->container)
-      )
-    while (WRAPPER(r)->obj && isWrapper(WRAPPER(r)->obj)
-          && (WRAPPER(WRAPPER(r)->obj)->container == 
-              WRAPPER(WRAPPER(r)->container)->obj)
-          )
-      {
-       /* Simplify wrapper */
-       Py_XINCREF(WRAPPER(WRAPPER(r)->obj)->obj);
-       ASSIGN(WRAPPER(r)->obj, WRAPPER(WRAPPER(r)->obj)->obj);
-      }
-
-  return r;
-err:
-  Py_DECREF(r);
-  return NULL;
-}
-
 static Wrapper *freeWrappers=0;
 static int nWrappers=0;
 #define MAX_CACHED_WRAPPERS 200
@@ -227,6 +194,49 @@
     {
       PyObject_DEL(self);
     }
+}
+
+static PyObject *
+__of__(PyObject *inst, PyObject *parent)
+{
+  PyObject *r, *t;
+
+  UNLESS(r=PyObject_GetAttr(inst, py__of__)) return NULL;
+  UNLESS(t=PyTuple_New(1)) goto err;
+  Py_INCREF(parent);
+  PyTuple_SET_ITEM(t,0,parent);
+  ASSIGN(r,PyObject_CallObject(r,t));
+  Py_DECREF(t);
+
+  if (r != NULL
+      && isWrapper(r) 
+      && WRAPPER(r)->container && isWrapper(WRAPPER(r)->container)
+      )
+    while (WRAPPER(r)->obj && isWrapper(WRAPPER(r)->obj)
+          && (WRAPPER(WRAPPER(r)->obj)->container == 
+              WRAPPER(WRAPPER(r)->container)->obj)
+          )
+      {
+        if (r->ob_refcnt !=1 )
+          {
+            t = newWrapper(WRAPPER(r)->obj, 
+                           WRAPPER(r)->container,
+                           (r->ob_type));
+            Py_DECREF(r);
+            if (t==NULL)
+              return NULL;
+            r = t;
+          }
+
+        /* Simplify wrapper */
+        Py_XINCREF(WRAPPER(WRAPPER(r)->obj)->obj);
+        ASSIGN(WRAPPER(r)->obj, WRAPPER(WRAPPER(r)->obj)->obj);
+      }
+
+  return r;
+err:
+  Py_DECREF(r);
+  return NULL;
 }
 
 static PyObject *

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

Reply via email to