Skip to content

Commit

Permalink
Refactor [module|capi]_ac_inner
Browse files Browse the repository at this point in the history
* The usual tabs/spaces/indent stuff.
* Make use of the fact that __new__ ensures that self->obj is never NULL
  • Loading branch information
stephan-hof committed Feb 22, 2017
1 parent 02a90a3 commit 6618e95
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions src/Acquisition/_Acquisition.c
Expand Up @@ -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 *
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6618e95

Please sign in to comment.