[Python-Dev] Possible C API problem?
Gary Robinson
grobinson at goombah.com
Tue Jul 5 23:52:31 CEST 2005
> You are doing something wrong. As getSumChiSquare is a METH_NOARGS
> method, it shouldn't have a PyObject*args argument.
While I am aware enough of your general expertise to be surprised if
you were in error in your statement below about VAR_NOARGS, your
statement obove does seem to contradict the docs:
METH_VARARGS
This is the typical calling convention, where the methods have the
type PyCFunction. The function expects two PyObject* values. The first
one is the self object for methods; for module functions, it has the
value given to Py_InitModule4() (or NULL if Py_InitModule() was
used). The second parameter (often called args) is a tuple object
representing all arguments. This parameter is typically processed
using PyArg_ParseTuple() or PyArg_UnpackTuple.
...
METH_NOARGS
Methods without parameters don't need to check whether arguments are
given if they are listed with the METH_NOARGS flag. They need to be of
type PyCFunction. When used with object methods, the first parameter
is typically named self and will hold a reference to the object
instance. In all cases the second parameter will be NULL.
----
(http://python.fyxm.net/doc/2.3.5/api/common-structs.html#l2h-832
In other words the docs seem to explicitly state that the args will be
supplied and what they will contain, so I'd assume that the C method
should have them in their declaration. Moreover, METH_NOARGS needs to
correspond to type PyCFunction, and the definition of type PyCFunction
states that it must receive two args of PyObject*.
Are the docs wrong or am I misreading them? Or are you wrong?
Re your other comments, as mentioned in my personal email, the word
done by folks in a couple of python forums in running tests does seem
to confirm that there is some kind of bug involving gcc 3.3. The bus
error appears independently of whether VAR_METHARGS or VAR_VARARGS is
used. Also, (again as mentioned in my personal email) I do have 4 F/T
experienced people working on this project, none of whom has the
expertise to resolve this. Given that it looks like a real bug was
uncovered, I think it was appropriate to post on the python forums
about this. I only posted to python-dev because it was suggested that I
do so by someone on the C++ sig.
Gary
--
Gary Robinson
CTO
Emergent Music, LLC
grobinson at goombah.com
207-942-3463
Company: http://www.goombah.com
Blog: http://www.garyrobinson.net
More information about the Python-Dev
mailing list