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

Andreas Jung andreas at andreas-jung.com
Tue Oct 21 08:44:40 EDT 2003


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

Modified Files:
      Tag: Zope-2_7-branch
	Acquisition.c 
Log Message:
     - Collector #1056: aq_acquire() ignored the default argument


=== Zope/lib/Components/ExtensionClass/src/Acquisition.c 1.61 => 1.61.4.1 ===
--- Zope/lib/Components/ExtensionClass/src/Acquisition.c:1.61	Tue Jun 10 11:28:46 2003
+++ Zope/lib/Components/ExtensionClass/src/Acquisition.c	Tue Oct 21 08:44:39 2003
@@ -1034,6 +1034,7 @@
 {
   PyObject *name, *filter=0, *extra=Py_None;
   PyObject *expl=0, *defalt=0;
+  PyObject *result;
   int explicit=1;
   int containment=0;
 
@@ -1047,10 +1048,23 @@
 
   if (filter==Py_None) filter=0;
 
-  return Wrapper_findattr(self,name,filter,extra,OBJECT(self),1,
+  result=Wrapper_findattr(self,name,filter,extra,OBJECT(self),1,
 			  explicit || 
 			  self->ob_type==(PyTypeObject*)&Wrappertype,
 			  explicit, containment);
+  if (result == NULL && defalt != NULL) {
+    /* contrary to "Python/bltinmodule.c:builtin_getattr" turn
+       only 'AttributeError' into a default value, such
+       that e.g. "ConflictError" and errors raised by the filter
+       are not mapped to the default value.
+    */
+    if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+      PyErr_Clear();
+      Py_INCREF(defalt);
+      result = defalt;
+    }
+  }
+  return result;
 }
 
 static PyObject *




More information about the Zope-Checkins mailing list