On Thu, 10 Feb 2005, Ralf W. Grosse-Kunstleve wrote:
--- Nick Rasmussen <nick@ilm.com> wrote:
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?
I applied this patch locally and tested it in 14 different configurations. It appears to work OK with Python 2.2, but leads to platform-specific fatal errors with Python 2.3 and 2.4 (Abort, Bus error, C assertions in Python, or plain wrong results). Here is the full damage:
http://cci.lbl.gov/cctbx_build/show_error_summary.cgi?build_tag=2005_02_10_1...
(This page will go away after a few days.)
Using the exact same sources, but without the patch above, eliminates all errors.
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. -nick