Python/C API and setattr
Thomas S. Strinnhed
thstr at serop.abb.se
Wed Jun 9 09:45:07 EDT 1999
Hi,
Thank you for a fast response.
Moshe Zadka wrote:
[my original message]
> You should return Py_None from a function. Every function called by
> Python has the following prototype:
> PyObject *f(PyObject *self, PyObject *args)
> (Actually, this is a lie. But a small white Knuth one)
> --
> Moshe Zadka <mzadka at geocities.com>.
> QOTD: My own exit is more likely to be horizontal then perpendicular.
Well I thought so too, but actually it must be something else,
cause it doesn't go away!!
static PyObject *counter_setattr(counterobject *self, char *name,
PyObject *v)
{
if(strcmp(name, "value") == 0)
{
self->value = (int)PyInt_AsLong(v);
Py_INCREF(Py_None);
return Py_None;
}
Py_INCREF(Py_None);
return Py_None;
}
Just doesn't help!!
Could there be something about this line;
self->value = (int)PyInt_AsLong(v);
(self->value is an int and v is PyObject*)
And about the prototype:
The few examples I've found about setattr are just like I've used it:
compare my prototype
static void counter_setattr(counterobject *self, char *name, PyObject
*v)
with this one from Objects\xxobject.c
static int xx_setattr(xxobject *xp, char *name, PyObject *v)
I think my main question would be:
Where to find detailed documentation/information about this?
and subquestion asked standing on my bare knees (?? :-)
What's happening here?? (Here beeing my code)
Admit it's tricky??
Many Thanks
-- Thomas S. Strinnhed, thstr at serop.abb.se
More information about the Python-list
mailing list