test if PyObject * points to real python object

Jeff Epler jepler at unpythonic.net
Wed Jun 23 23:09:46 CEST 2004


On Sat, Jun 19, 2004 at 03:11:32PM +1200, David McNab wrote:
> Hi,
> 
> With the Python/C API, how do i test if a given PyObject * actually 
> points to a real/valid python object?

In most places in the API, it's illegal for a PyObject* to point to
something other than a real/valid Python object, except that sometimes
NULL is allowed instead.  With proper refcounting, it's impossible for a
valid pointer to become invalid.

So, really, the way you tell is by the absence of a "signal 11" or
unexpected results.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040623/6d051fb5/attachment.sig>


More information about the Python-list mailing list