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>
- Various places within the bindings use PyArg_ParseTuple[AndKeywords] to
extract (char*) string arguments. These are pointers to the internal
representation of a PyStringObject, and shouldn't be modified, hence
it's safest to explicitly mark these values as (const char*), rather
than just (char*).
Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
- Objects supporting __len__() use (len > 0) for boolean representation,
which normally makes sense but as the match iterator count is often
zero despite the iterator actually existing and returning something,
and breaks existing code (rpmlint at least)
- Adding a __bool__() (known as __nonzero__() in Python < 3) method
returning true for non-NULL iterator fixes this and gives more
meaningful answers than pre 4.8.0 which simply always returned True
The layout of PyVarObject changed between python 2 and python 3, and this leads
to the existing code for all of the various PyTypeObject initializers failing to
compile with python 3
Change the way we initialize these structs to use PyVarObject_HEAD_INIT directly,
rather than merely PyObject_HEAD_INIT, so that it compiles cleanly with both major
versions of Python
Python 2's various object structs use macros to implement common fields at the top of each
struct.
Python 3's objects instead embed a PyObject struct as the first member within the more refined
object structs.
Use the Py_TYPE() macro when accessing ob_type in order to encapsulate this difference.
- use PyErr_WarnEx() for better control and leave the tracking up to python
- use PendingDeprecationWarning for now
- document the replacing functionality in the deprecation messages
- make hdr.sprintf() just an alias to hdr.format() without deprecating,
at least for now it'd be only a gratuitous incompatible change on python side
- raise exception in tagNumFromPyObject(), not in 12 different callers
- check against RPMTAG_NOT_FOUND consistently instead of -1 and whatnot
- unknown tags are value, not key or type errors
- typedef'ed as int32_t for now, negative values used in some places for
error cases
- easy to grep, easy to change...
- add RPMTAG_NOT_FOUND define, used in place of -1 "magic",
- python: argument to ts.addErase (if integer) deletes that instance.
- python: rpmmi methods to return this instance, and number of members.
CVS patchset: 5620
CVS date: 2002/08/09 23:14:10
- python: the death of rpm.headerFromPackage(), use ts.hdrFromFdno().
- python: permit direct ts.dbMatch() python iterations.
- python: the death of rpm.checksig(), use ts.hdrFromFdno() instead.
CVS patchset: 5603
CVS date: 2002/08/05 21:46:50