The following causes a seg fault because it attempts to reference a CTree 
node which does not exist:

>>> import gtk
>>> tree = gtk.GtkCTree()
>>> n = tree.node_nth(10)
>>> print n.parent

Looking at the source, it appears that the C api function returns NULL in
this case, but this pointer is passed to PyGtkCTreeNode_New.  The pointer
is then stored and dereferenced in the get attr function, causing the seg
fault.  There are a couple ways to fix this that are relatively easy to
implement:
  * Return None if the pointer is NULL.
  * Throw an exception if NULL is returned.

My question is which is the preferred method in this case and whether all
the cases where a node is returned should be handled the same way -- are
there cases where NULL would be an acceptable value rather than a result
of passing incorrect values to function.  Also, should other boxed types
act the same way.

Thanks,

John

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to