Commit 95339447 authored by Andreas Jung's avatar Andreas Jung

      - Collector #1879: applied patch by Dieter Maurer to fix a bug in 
        ac_aquire() ignoring the default argument
parent e871f31d
...@@ -1059,6 +1059,7 @@ Wrapper_acquire_method(Wrapper *self, PyObject *args, PyObject *kw) ...@@ -1059,6 +1059,7 @@ Wrapper_acquire_method(Wrapper *self, PyObject *args, PyObject *kw)
PyObject *expl=0, *defalt=0; PyObject *expl=0, *defalt=0;
int explicit=1; int explicit=1;
int containment=0; int containment=0;
PyObject *result; /* DM 2005-08-25: argument "default" ignored */
UNLESS (PyArg_ParseTupleAndKeywords( UNLESS (PyArg_ParseTupleAndKeywords(
args, kw, "O|OOOOi", acquire_args+1, args, kw, "O|OOOOi", acquire_args+1,
...@@ -1070,12 +1071,34 @@ Wrapper_acquire_method(Wrapper *self, PyObject *args, PyObject *kw) ...@@ -1070,12 +1071,34 @@ Wrapper_acquire_method(Wrapper *self, PyObject *args, PyObject *kw)
if (filter==Py_None) filter=0; 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, return Wrapper_findattr(self,name,filter,extra,OBJECT(self),1,
explicit || explicit ||
self->ob_type==(PyTypeObject*)&Wrappertype, self->ob_type==(PyTypeObject*)&Wrappertype,
explicit, containment); 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 * static PyObject *
Wrapper_inContextOf(Wrapper *self, PyObject *args) Wrapper_inContextOf(Wrapper *self, PyObject *args)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment