[Zope-Checkins] CVS: Zope/lib/Components/ExtensionClass/src - Acquisition.c:1.53.38.1

Matthew T. Kromer matt@zope.com
Tue, 11 Dec 2001 14:53:33 -0500


Update of /cvs-repository/Zope/lib/Components/ExtensionClass/src
In directory cvs.zope.org:/tmp/cvs-serv11475

Modified Files:
      Tag: Zope-2_5-branch
	Acquisition.c 
Log Message:
Put some assertions in that acquistion wrappers aren't wrapping themselves.
May help flush Martijn Faassen's DOM related crashes.


=== Zope/lib/Components/ExtensionClass/src/Acquisition.c 1.53 => 1.53.38.1 ===
 
   UNLESS(PyArg_Parse(args,"(OO)",&obj,&container)) return NULL;
+
+  if (obj == self) {
+  	PyErr_SetObject(PyExc_ValueError,
+		"Cannot wrap acquisition wrapper in itself (Wrapper__init__)");
+  	return NULL;
+  }
+
   Py_INCREF(obj);
   Py_INCREF(container);
   self->obj=obj;
@@ -218,6 +225,13 @@
       UNLESS(self = PyObject_NEW(Wrapper, Wrappertype)) return NULL;
     }
 
+  if (obj == self) {
+  	PyErr_SetObject(PyExc_ValueError,
+		"Cannot wrap acquisition wrapper in itself (newWrapper)");
+	Py_DECREF(self);
+	return NULL;
+  }
+
   Py_INCREF(Wrappertype);
   Py_XINCREF(obj);
   Py_XINCREF(container);
@@ -430,6 +444,11 @@
     {
       if (isWrapper(self->obj))
 	{
+	  if (WRAPPER(self->obj) == self) {
+	  	PyErr_SetObject(PyExc_RuntimeError,
+			"Recursion detected in acquisition wrapper");
+		return NULL;
+	  }
 	  if ((r=Wrapper_findattr(WRAPPER(self->obj),
 				 oname, filter, extra, orig, 1,