- Add NULL checks and add/adjust comments where appropriate.
- The remaining callers should handle NULL fi gracefully if not
entirely correctly: rpmfiFC() returns 0 on NULL fi, so these
callers just see the erronous file info set as "no files" case.
Something to fine-tune later...
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>
- Hasty push-finger syndrom, while its not exactly plain wrong to
do things this way, it doesn't really make sense for these types
either. Python's own file object permits reinitialization though,
so leaving rpm.fd() the way it is now.
- This reverts the following commits:
d056df28c33f77c3146d7214b2e0a2dc50fb2863
- Move all actual initialization work into tp_init, permit
reinitialization without leaking and use PyType_GenericNew for
tp_new, eliminate internal rpmfi_Wrap() use.
There's one user for rpmfi_Wrap() in rpmte-py.c which needs fixing
later...
- Remove unused fiFromFi() helper function
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.
- these violate the intended use of tp_print, python docs state
"A type should never implement tp_print in a way that produces
different output than tp_repr or tp_str would."
- 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
- Internally file sizes are still stored as 32bit, going to 64bit wouldn't
make much sense (would only waste memory for nothing) as long as we're
bound by cpio's 32bit per-file limit. Being "64bit ready" for filesizes
doesn't hurt anything though...
- use same code for creating the digest object on iteration and method call
- fi.MD5() left around as alias for fi.Digest(), dunno if that's the best
thing to do but it's just a python string so returned size isn't that
critical..
- put some consistency into include ordering
- everything (apart from bits missed ;) is now ordered like this
1. "system.h"
2. other system includes
3. rpm public headers
4. rpm private headers
5. "debug.h"