I took a look at the C code generated by PyBindGen.
(Fortunately PyBindGen generated exceptionally readable code.)
There I could see that my __nonzero__ method was added to the tp_methods member of the type object.
It should have been added as the nb_nonzero member of the tp_as_number member of the type object; see http://docs.python.org/c-api/typeobj.html#number-object-structures
So it seems that either I have added __nonzero__ the wrong way, or this is a PyBindGen bug.
I took a look at the C code generated by PyBindGen. docs.python. org/c-api/ typeobj. html#number- object- structures
(Fortunately PyBindGen generated exceptionally readable code.)
There I could see that my __nonzero__ method was added to the tp_methods member of the type object.
It should have been added as the nb_nonzero member of the tp_as_number member of the type object; see
http://
So it seems that either I have added __nonzero__ the wrong way, or this is a PyBindGen bug.