From 6618e95c073c904312fb54a17b35d744251e2333 Mon Sep 17 00:00:00 2001 From: stephan-hof Date: Sun, 19 Feb 2017 10:18:32 +0100 Subject: [PATCH] Refactor [module|capi]_ac_inner * The usual tabs/spaces/indent stuff. * Make use of the fact that __new__ ensures that self->obj is never NULL --- src/Acquisition/_Acquisition.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/src/Acquisition/_Acquisition.c b/src/Acquisition/_Acquisition.c index 9621c54..235258d 100644 --- a/src/Acquisition/_Acquisition.c +++ b/src/Acquisition/_Acquisition.c @@ -1826,36 +1826,20 @@ module_aq_self(PyObject *ignored, PyObject *self) static PyObject * capi_aq_inner(PyObject *self) { - PyObject *result; - if (! isWrapper(self)) - { - Py_INCREF(self); - return self; - } - - if (WRAPPER(self)->obj) - { - result=WRAPPER(self)->obj; - while (isWrapper(result) && WRAPPER(result)->obj) - { - self=result; - result=WRAPPER(result)->obj; - } - result=self; + if (isWrapper(self)) { + while (isWrapper(WRAPPER(self)->obj)) { + self = WRAPPER(self)->obj; + } } - else result=Py_None; - Py_INCREF(result); - return result; + Py_INCREF(self); + return self; } static PyObject * -module_aq_inner(PyObject *ignored, PyObject *args) +module_aq_inner(PyObject *ignored, PyObject *self) { - PyObject *self; - - UNLESS (PyArg_ParseTuple(args, "O", &self)) return NULL; - return capi_aq_inner(self); + return capi_aq_inner(self); } static PyObject * @@ -1991,7 +1975,7 @@ static struct PyMethodDef methods[] = { "aq_parent(ob) -- Get the parent of an object"}, {"aq_self", (PyCFunction)module_aq_self, METH_O, "aq_self(ob) -- Get the object with the outermost wrapper removed"}, - {"aq_inner", (PyCFunction)module_aq_inner, METH_VARARGS, + {"aq_inner", (PyCFunction)module_aq_inner, METH_O, "aq_inner(ob) -- " "Get the object with all but the innermost wrapper removed"}, {"aq_chain", (PyCFunction)module_aq_chain, METH_VARARGS,