diff options
author | David Malcolm <dmalcolm@redhat.com> | 2011-12-22 18:59:51 -0500 |
---|---|---|
committer | Ales Kozumplik <akozumpl@redhat.com> | 2012-01-02 08:39:39 +0100 |
commit | 59378e52205728f7a78be1b329aa159f72e5686e (patch) | |
tree | 447d05eab84f6b1e1a16069998f7be6098388377 /python/rpmmi-py.c | |
parent | fdba2538855d8ad94bbe5e9c21c8564d01b20f1e (diff) | |
download | librpm-tizen-59378e52205728f7a78be1b329aa159f72e5686e.tar.gz librpm-tizen-59378e52205728f7a78be1b329aa159f72e5686e.tar.bz2 librpm-tizen-59378e52205728f7a78be1b329aa159f72e5686e.zip |
fix the signatures of the METH_NOARGS callbacks
Various Python method callbacks have signatures of the form:
static PyObject *
foo(some_object_subclass *obj)
and are registered within the PyMethodDef tables with the METH_NOARGS
flag [1], with a cast to (PyCFunction) due to the PyObject/subclass
mismatch.
However, such callbacks do receive two arguments: they are invoked with
a signature of this form:
static PyObject *
foo(some_object_subclass *obj, PyObject *ignored)
The CPython interpreter only uses METH_NOARGS to allow it to pass NULL as the
second parameter: there are still two parameters. The dispatch code is in
Python's Python/ceval.c:call_function:
if (flags & METH_NOARGS && na == 0) {
C_TRACE(x, (*meth)(self,NULL));
}
The fact that this has ever worked may be a coincidence of the
platform/compiler's calling conventions, and I don't think it's guaranteed to
keep working.
[1] http://docs.python.org/c-api/structures.html#METH_NOARGS
Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
Diffstat (limited to 'python/rpmmi-py.c')
-rw-r--r-- | python/rpmmi-py.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c index 977e47552..8e670ce02 100644 --- a/python/rpmmi-py.c +++ b/python/rpmmi-py.c @@ -78,7 +78,7 @@ rpmmi_iternext(rpmmiObject * s) } static PyObject * -rpmmi_Instance(rpmmiObject * s) +rpmmi_Instance(rpmmiObject * s, PyObject * unused) { int rc = 0; @@ -89,7 +89,7 @@ rpmmi_Instance(rpmmiObject * s) } static PyObject * -rpmmi_Count(rpmmiObject * s) +rpmmi_Count(rpmmiObject * s, PyObject * unused) { DEPRECATED_METHOD("use len(mi) instead"); return Py_BuildValue("i", PyMapping_Size((PyObject *)s)); |