[C++-sig] functions not showing up in pydoc

Jonathan Brandmeyer jbrandmeyer at earthlink.net
Thu Feb 17 04:59:44 CET 2005


On Wed, 2005-02-16 at 15:26 -0800, Nick Rasmussen wrote:
> On Thu, 10 Feb 2005, Nick Rasmussen wrote:
> > 
> > Thanks for testing it out.  It's been working fine for me here
> > (suse9.1 amd64 with python2.3), but I'll see if I can figure
> > out what the right fix is.
> > 
> > I took a quick look at PyCFunction_Type, and it's tp_flags are
> > set to:
> > 
> >         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
> > 
> > Two things make me suspicious: absent is Py_TPFLAGS_BASETYPE,
> > and I'm not sure if subclasses of gc-aware classes need to
> > support garbage collection as well.
> > 
> > I'll run it by our local python expert and see what he has
> > to say.
> 
> 
> I ran this question past python-dev, and they said that
> one way to do this is to have PyCFunction_Type as the
> __class__ attribute:
> 
> http://thread.gmane.org/gmane.comp.python.devel/66557
> 
> I'm now running boost::python with the following patch applied
> (docstring concatenation and the __class__ attribute), and
> this seems to be working for me.

I'm more than a little leery of changing the __class__ attribute, since
all instances of Boost.Python.function would be lying about what they
are.

If x and f.x are Boost.Python.function objects with docstrings, than
inspect.getdoc(x) and inspect.getdoc(f.x) work.
inspect.ismethoddescriptor(x) and inspect.ismethod(f.x) also return
True.

Where does pydoc test whether or not to document something as a
function?

-Jonathan




More information about the Cplusplus-sig mailing list