[C++-sig] functions not showing up in pydoc
Nick Rasmussen
nick at ilm.com
Tue Feb 8 04:00:17 CET 2005
I'm running into a problem with functions at the module level not
showing up in pydoc. The problem is that the type of the function
object in the module is:
>>> type(testfoo.foo)
<type 'Boost.Python.function'>
Which isn't a sublcass of <type 'builtin_function_or_method'>
When pydoc walks the module it only documents routines that are
either builtin (according to inspect.isbuiltin) or are objects
whose module can be deduced via inspect.getmodule.
I modified function.cpp with:
--- libs/python/src/object/function.cpp.orig 2005-02-07 17:11:52.000066304 -0800
+++ libs/python/src/object/function.cpp 2005-02-07 16:55:24.000120507 -0800
@@ -608,7 +608,7 @@
0, /* tp_methods */
0, // func_memberlist, /* tp_members */
function_getsetlist, /* tp_getset */
- 0, /* tp_base */
+ &PyCFunction_Type, /* tp_base */
0, /* tp_dict */
function_descr_get, /* tp_descr_get */
0, /* tp_descr_set */
and it seemed to fix it. Is this right, or is there a different
way that functions should get exposed such that pydoc can understand
them?
Also, for functions with overloads, only one of the docstrings
is printed out. It looks like
void function::add_to_namespace(
object const& name_space, char const* name_, object const& attribute, char const* doc)
just replaces the old doc string instead of appending the new one
to the old.
-nick
More information about the Cplusplus-sig
mailing list