C Ext Questions

Michael Hudson mwh at python.net
Wed Jul 21 14:06:04 EDT 2004


djw <donald.welch at hp.com> writes:

> Hello, I have a couple of questions about some code in a C extension module.
> First, how would I convert a Python string return value from a call to
> PyObject_CallFunction into a C void * buffer? 

PyString_AsString().  Do check for NULL return in case the the object
isn't a string...

> Second, do I need to call Py_XINCREF() on my callback function?

Yes, though the code as posted would be fine with Py_INCREF().

Have you read the fine (well, ish) manuals on this sort of thing?

Cheers,
mwh

-- 
  ARTHUR:  Ford, you're turning into a penguin, stop it.
                    -- The Hitch-Hikers Guide to the Galaxy, Episode 2



More information about the Python-list mailing list