Log message for revision 38587:
  
        - Collector #1879: applied patch by Dieter Maurer to fix a bug in 
          ac_aquire() ignoring the default argument
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Acquisition/_Acquisition.c

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt  2005-09-24 12:10:07 UTC (rev 38586)
+++ Zope/trunk/doc/CHANGES.txt  2005-09-24 12:11:13 UTC (rev 38587)
@@ -42,6 +42,9 @@
 
     Bugs Fixed
 
+      - Collector #1879: applied patch by Dieter Maurer to fix a bug in 
+        ac_aquire() ignoring the default argument
+
       - Collector #1864, #1906: fixed header normalization in appendHeader()
 
       - Collector #1899: fixed migration issue when using export/import for

Modified: Zope/trunk/lib/python/Acquisition/_Acquisition.c
===================================================================
--- Zope/trunk/lib/python/Acquisition/_Acquisition.c    2005-09-24 12:10:07 UTC 
(rev 38586)
+++ Zope/trunk/lib/python/Acquisition/_Acquisition.c    2005-09-24 12:11:13 UTC 
(rev 38587)
@@ -1059,6 +1059,7 @@
   PyObject *expl=0, *defalt=0;
   int explicit=1;
   int containment=0;
+  PyObject *result; /* DM 2005-08-25: argument "default" ignored */
 
   UNLESS (PyArg_ParseTupleAndKeywords(
             args, kw, "O|OOOOi", acquire_args+1,
@@ -1070,12 +1071,34 @@
 
   if (filter==Py_None) filter=0;
 
+  /* DM 2005-08-25: argument "default" ignored -- fix it! */
+# if 0
   return Wrapper_findattr(self,name,filter,extra,OBJECT(self),1,
                          explicit || 
                          self->ob_type==(PyTypeObject*)&Wrappertype,
                          explicit, containment);
+# else
+  result = Wrapper_findattr(self,name,filter,extra,OBJECT(self),1,
+                         explicit || 
+                         self->ob_type==(PyTypeObject*)&Wrappertype,
+                         explicit, containment);
+  if (result == NULL && defalt != NULL) {
+    /* as "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;
+# endif
 }
 
+
 static PyObject *
 Wrapper_inContextOf(Wrapper *self, PyObject *args)
 {

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

Reply via email to