diff -ur boost_1_33_1_ori/Jamfile boost_1_33_1/Jamfile
--- boost_1_33_1_ori/Jamfile	2005-11-08 05:39:45.000000000 +0100
+++ boost_1_33_1/Jamfile	2006-04-06 11:41:39.000000000 +0200
@@ -122,6 +122,7 @@
 # object code libraries
 local lib-locate = [ MATCH "^--libdir=(.*)" : $(ARGV) ] ;
 lib-locate ?= $(exec-locate)/lib ;
+gLIB_INSTALL_DIR ?= $(lib-locate) ;
 
 # where to build
 local all-locate = [ MATCH "^--builddir=(.*)" : $(ARGV) ] ;
diff -ur boost_1_33_1_ori/libs/python/build/Jamfile boost_1_33_1/libs/python/build/Jamfile
--- boost_1_33_1_ori/libs/python/build/Jamfile	2005-05-20 22:12:29.000000000 +0200
+++ boost_1_33_1/libs/python/build/Jamfile	2006-04-06 11:41:39.000000000 +0200
@@ -62,7 +62,7 @@
       <define>BOOST_PYTHON_SOURCE
       $(bpl-linkflags)
         <msvc-stlport><release>$(msvc-stlport-workarounds)
-        <darwin><*><linkflags>-bind_at_load
+        <darwin><*><linkflags>"-undefined dynamic_lookup -W,l-bind_at_load"
         <gcc-3_3-darwin><*><linkflags>-bind_at_load
       ;
 
diff -ur boost_1_33_1_ori/libs/test/build/Jamfile boost_1_33_1/libs/test/build/Jamfile
--- boost_1_33_1_ori/libs/test/build/Jamfile	2005-08-23 04:19:44.000000000 +0200
+++ boost_1_33_1/libs/test/build/Jamfile	2006-04-06 11:41:39.000000000 +0200
@@ -75,13 +75,16 @@
 if $(TEST_DLLs)
 {
 dll boost_prg_exec_monitor    : <template>boost_test_lib
-                                ../src/$(PRG_EXEC_MON_SOURCES).cpp ;
+                                ../src/$(PRG_EXEC_MON_SOURCES).cpp 
+                       : <darwin><*><linkflags>"-undefined dynamic_lookup" ;
 
 dll boost_test_exec_monitor   : <template>boost_test_lib
-                                ../src/$(TEST_EXEC_MON_SOURCES).cpp ; 
+                                ../src/$(TEST_EXEC_MON_SOURCES).cpp  
+                       : <darwin><*><linkflags>"-undefined dynamic_lookup" ;
 
 dll boost_unit_test_framework : <template>boost_test_lib
-                                ../src/$(UTF_SOURCES).cpp ;
+                                ../src/$(UTF_SOURCES).cpp 
+                       : <darwin><*><linkflags>"-undefined dynamic_lookup" ;
 }
 
 install test lib
diff -ur boost_1_33_1_ori/tools/build/v1/boost-base.jam boost_1_33_1/tools/build/v1/boost-base.jam
--- boost_1_33_1_ori/tools/build/v1/boost-base.jam	2005-10-20 00:34:04.000000000 +0200
+++ boost_1_33_1/tools/build/v1/boost-base.jam	2006-04-06 14:35:06.000000000 +0200
@@ -2618,7 +2618,6 @@
     if <threading>multi in $(properties) { thread-tag = mt ; }
     
     local runtime-tag = ;
-    if <runtime-link>static in $(properties) { runtime-tag += s ; }
     if <runtime-build>debug in $(properties) { runtime-tag += g ; }
     if [ MATCH .*(debug-python).* : $(variant) ] { runtime-tag += y ; }
     else { if [ MATCH .*(debug).* : $(variant) ] { runtime-tag += d ; } }
diff -ur boost_1_33_1_ori/tools/build/v1/darwin-tools.jam boost_1_33_1/tools/build/v1/darwin-tools.jam
--- boost_1_33_1_ori/tools/build/v1/darwin-tools.jam	2005-05-11 08:15:20.000000000 +0200
+++ boost_1_33_1/tools/build/v1/darwin-tools.jam	2006-04-06 14:42:45.000000000 +0200
@@ -187,7 +187,7 @@
     && \
     $(.GCC_BIN_DIR)$(.GXX) $(LINKFLAGS) -o "$(<[1])" "$(<[1]:S=.lo)" \
-      -F$(FRAMEWORKS:D) -framework$(_)$(FRAMEWORKS:D=) \
-      -L"$(LIBPATH:T)" -L"$(STDLIBPATH:T)" "$(NEEDLIBS)" "$(NEEDLIBS)" -l$(FINDLIBS) -dynamiclib -install_name "$(<[1]:D=:S=.dylib)" \
+      -L"$(LIBPATH:T)" -L"$(STDLIBPATH:T)" "$(NEEDLIBS)" "$(NEEDLIBS)" -l$(FINDLIBS) -dynamiclib \
+      -install_name "$(<[1]:D=$(gLIB_INSTALL_DIR):S=.dylib)" -compatibility_version $(DLLVERSION) -current_version $(DLLVERSION) \
     && \
     rm -f "$(<[1]:S=.lo)"
 }
--- boost_1_33_1/tools/build/v1/python.jam~	2005-10-26 05:30:41.000000000 +0200
+++ boost_1_33_1/tools/build/v1/python.jam	2006-07-20 14:17:09.000000000 +0200
@@ -76,7 +76,7 @@
 
 	if $(OS) = MACOSX
 	{
-		PYTHON_EMBEDDED_LIBRARY = ;
+		PYTHON_EMBEDDED_LIBRARY = python$(PYTHON_VERSION) ;
 	}
 	else if $(OS) = SOLARIS
 	{
--- boost_1_33_1/tools/build/v1/gcc-tools.jam~	2005-11-19 20:21:16.000000000 +0100
+++ boost_1_33_1/tools/build/v1/gcc-tools.jam	2006-07-20 14:40:58.000000000 +0200
@@ -120,8 +120,8 @@
         # MacOS X, doesn't need any threading options set
         # -lpthread is linked to by default.
         # There is no gcc/g++, we need to use cc/c++ instead:
-        .GCC ?= cc ;
-        .GXX ?= c++ ;
+        #.GCC ?= cc ;
+        #.GXX ?= c++ ;
         }
     case *BSD :
         {
@@ -362,7 +362,17 @@
 }
 else
 {
-    flags gcc LINKFLAGS <target-type>$(SHARED_TYPES) : -shared ;
+    switch $(JAMUNAME)
+    {
+    case Darwin :
+        {
+        flags gcc LINKFLAGS <target-type>$(SHARED_TYPES) : -dynamiclib ;
+        }
+    case * :
+        {
+        flags gcc LINKFLAGS <target-type>$(SHARED_TYPES) : -shared ;
+        }
+    }
 }
 
 flags gcc LIBPATH <library-path> ;
Index: ./boost/python/docstring_options.hpp
===================================================================
RCS file: ./boost/python/docstring_options.hpp
diff -N ./boost/python/docstring_options.hpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ boost_1_33_1/boost/python/docstring_options.hpp	12 Oct 2006 06:41:18 -0000	1.3
@@ -0,0 +1,76 @@
+// Copyright Ralf W. Grosse-Kunstleve 2006.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+#ifndef DOCSTRING_OPTIONS_RWGK20060111_HPP
+# define DOCSTRING_OPTIONS_RWGK20060111_HPP
+
+#include <boost/python/object/function.hpp>
+
+namespace boost { namespace python {
+
+// Note: the static data members are defined in object/function.cpp
+
+class BOOST_PYTHON_DECL docstring_options : boost::noncopyable
+{
+  public:
+      docstring_options(bool show_all=true)
+      {
+          previous_show_user_defined_ = show_user_defined_;
+          previous_show_signatures_ = show_signatures_;
+          show_user_defined_ = show_all;
+          show_signatures_ = show_all;
+      }
+
+      docstring_options(bool show_user_defined, bool show_signatures)
+      {
+          previous_show_user_defined_ = show_user_defined_;
+          previous_show_signatures_ = show_signatures_;
+          show_user_defined_ = show_user_defined;
+          show_signatures_ = show_signatures;
+      }
+
+      ~docstring_options()
+      {
+          show_user_defined_ = previous_show_user_defined_;
+          show_signatures_ = previous_show_signatures_;
+      }
+
+      void
+      disable_user_defined() { show_user_defined_ = false; }
+
+      void
+      enable_user_defined() { show_user_defined_ = true; }
+
+      void
+      disable_signatures() { show_signatures_ = false; }
+
+      void
+      enable_signatures() { show_signatures_ = true; }
+
+      void
+      disable_all()
+      {
+        show_user_defined_ = false;
+        show_signatures_ = false;
+      }
+
+      void
+      enable_all()
+      {
+        show_user_defined_ = true;
+        show_signatures_ = true;
+      }
+
+      friend struct objects::function;
+
+  private:
+      static volatile bool show_user_defined_;
+      static volatile bool show_signatures_;
+      bool previous_show_user_defined_;
+      bool previous_show_signatures_;
+};
+
+}} // namespace boost::python
+
+#endif // DOCSTRING_OPTIONS_RWGK20060111_HPP
Index: boost/python/detail/api_placeholder.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/detail/api_placeholder.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -w -u -r1.4 -r1.5
--- boost/python/detail/api_placeholder.hpp	26 Jul 2004 00:32:07 -0000	1.4
+++ boost_1_33_1/boost/python/detail/api_placeholder.hpp	12 Jan 2006 21:33:01 -0000	1.5
@@ -2,17 +2,14 @@
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
+
+// DEPRECATED HEADER (2006 Jan 12)
+// Provided only for backward compatibility.
+// The boost::python::len() function is now defined in object.hpp.
+
 #ifndef BOOST_PYTHON_API_PLACE_HOLDER_HPP
 #define BOOST_PYTHON_API_PLACE_HOLDER_HPP
 
-namespace boost { namespace python {
-
-    inline long len(object const& obj)
-    {
-        long result = PyObject_Length(obj.ptr());
-        if (PyErr_Occurred()) throw_error_already_set();
-        return result;
-    }
-}} // namespace boost::python
+#include <boost/python/object.hpp>
 
 #endif // BOOST_PYTHON_API_PLACE_HOLDER_HPP
Index: boost/python/object/function.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/object/function.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -w -u -r1.20 -r1.21
--- boost/python/object/function.hpp	26 Jul 2004 00:32:07 -0000	1.20
+++ boost_1_33_1/boost/python/object/function.hpp	12 Jan 2006 00:32:04 -0000	1.21
@@ -40,6 +40,8 @@
     object const& name() const;
     
  private: // helper functions
+    object signature(bool show_return_type=false) const;
+    object signatures(bool show_return_type=false) const;
     void argument_error(PyObject* args, PyObject* keywords) const;
     void add_overload(handle<function> const&);
     
Index: boost/python/list.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/list.hpp,v
retrieving revision 1.13
retrieving revision 1.15
diff -u -b -w -u -r1.13 -r1.15
--- boost/python/list.hpp	26 Jul 2004 00:32:05 -0000	1.13
+++ boost_1_33_1/boost/python/list.hpp	26 Sep 2006 00:25:06 -0000	1.15
@@ -9,6 +9,7 @@
 
 # include <boost/python/object.hpp>
 # include <boost/python/converter/pytype_object_mgr_traits.hpp>
+# include <boost/python/ssize_t.hpp>
 
 namespace boost { namespace python { 
 
@@ -24,11 +25,11 @@
     
       long index(object_cref value) const; // return index of first occurrence of value
 
-      void insert(int index, object_cref); // insert object before index
+      void insert(ssize_t index, object_cref); // insert object before index
       void insert(object const& index, object_cref);
 
       object pop(); // remove and return item at index (default last)
-      object pop(long index);
+      object pop(ssize_t index);
       object pop(object const& index);
 
       void remove(object_cref value); // remove first occurrence of value
@@ -86,7 +87,7 @@
     }
     
     template <class T>
-    void insert(int index, T const& x) // insert object before index
+    void insert(ssize_t index, T const& x) // insert object before index
     {
         base::insert(index, object(x));
     }
@@ -98,7 +99,7 @@
     }
 
     object pop() { return base::pop(); }
-    object pop(long index) { return base::pop(index); }
+    object pop(ssize_t index) { return base::pop(index); }
     
     template <class T>
     object pop(T const& index)
Index: boost/python/object.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/object.hpp,v
retrieving revision 1.9
retrieving revision 1.12
diff -u -b -w -u -r1.9 -r1.12
--- boost/python/object.hpp	26 Jul 2004 00:32:05 -0000	1.9
+++ boost_1_33_1/boost/python/object.hpp	26 Sep 2006 00:25:06 -0000	1.12
@@ -5,7 +5,7 @@
 #ifndef OBJECT_DWA2002612_HPP
 # define OBJECT_DWA2002612_HPP
 
-# include <boost/python/detail/prefix.hpp>
+# include <boost/python/ssize_t.hpp>
 # include <boost/python/object_core.hpp>
 # include <boost/python/object_attributes.hpp>
 # include <boost/python/object_items.hpp>
@@ -13,4 +13,15 @@
 # include <boost/python/object_operators.hpp>
 # include <boost/python/converter/arg_to_python.hpp>
 
+namespace boost { namespace python {
+
+    inline ssize_t len(object const& obj)
+    {
+        ssize_t result = PyObject_Length(obj.ptr());
+        if (PyErr_Occurred()) throw_error_already_set();
+        return result;
+    }
+
+}} // namespace boost::python
+
 #endif // OBJECT_DWA2002612_HPP
Index: boost/python/converter/builtin_converters.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/converter/builtin_converters.hpp,v
retrieving revision 1.25
retrieving revision 1.28
diff -u -b -w -u -r1.25 -r1.28
--- boost/python/converter/builtin_converters.hpp	8 Sep 2004 19:18:57 -0000	1.25
+++ boost_1_33_1/boost/python/converter/builtin_converters.hpp	26 Sep 2006 00:25:06 -0000	1.28
@@ -7,6 +7,7 @@
 # include <boost/python/detail/prefix.hpp>
 # include <boost/python/detail/none.hpp>
 # include <boost/python/handle.hpp>
+# include <boost/python/ssize_t.hpp>
 # include <boost/implicit_cast.hpp>
 # include <string>
 # include <complex>
@@ -115,9 +116,9 @@
 
 BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x))
 BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x))
-BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast<int>(x.size())))
-# ifndef BOOST_NO_STD_WSTRING
-BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast<int>(x.size())))
+BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast<ssize_t>(x.size())))
+#if defined(Py_USING_UNICODE) && !defined(BOOST_NO_STD_WSTRING)
+BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast<ssize_t>(x.size())))
 # endif 
 BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, ::PyFloat_FromDouble(x))
 BOOST_PYTHON_TO_PYTHON_BY_VALUE(double, ::PyFloat_FromDouble(x))
Index: libs/python/src/list.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/python/src/list.cpp,v
retrieving revision 1.8
retrieving revision 1.10
diff -u -b -w -u -r1.8 -r1.10
--- libs/python/src/list.cpp	26 Jul 2004 00:32:11 -0000	1.8
+++ boost_1_33_1/libs/python/src/list.cpp	26 Sep 2006 00:25:07 -0000	1.10
@@ -3,6 +3,7 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 #include <boost/python/list.hpp>
+#include <boost/python/ssize_t.hpp>
 
 namespace boost { namespace python { namespace detail {
 
@@ -53,7 +54,7 @@
     return result;
 }
 
-void list_base::insert(int index, object_cref item)
+void list_base::insert(ssize_t index, object_cref item)
 {
     if (PyList_CheckExact(this->ptr()))
     {
@@ -79,7 +80,7 @@
     return this->attr("pop")();
 }
 
-object list_base::pop(long index)
+object list_base::pop(ssize_t index)
 {
     return this->pop(object(index));
 }
Index: libs/python/src/object_protocol.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/python/src/object_protocol.cpp,v
retrieving revision 1.7
retrieving revision 1.9
diff -u -b -w -u -r1.7 -r1.9
--- libs/python/src/object_protocol.cpp	26 Jul 2004 00:32:11 -0000	1.7
+++ boost_1_33_1/libs/python/src/object_protocol.cpp	26 Sep 2006 00:25:07 -0000	1.9
@@ -6,6 +6,7 @@
 #include <boost/python/object_protocol.hpp>
 #include <boost/python/errors.hpp>
 #include <boost/python/object.hpp>
+#include <boost/python/ssize_t.hpp>
 
 namespace boost { namespace python { namespace api {
 
@@ -106,7 +107,7 @@
       PySequenceMethods *sq = tp->tp_as_sequence;
 
       if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) {
-          int ilow = 0, ihigh = INT_MAX;
+          ssize_t ilow = 0, ihigh = ssize_t_max;
           if (!_PyEval_SliceIndex(v, &ilow))
               return NULL;
           if (!_PyEval_SliceIndex(w, &ihigh))
@@ -133,7 +134,7 @@
       PySequenceMethods *sq = tp->tp_as_sequence;
 
       if (sq && sq->sq_slice && ISINT(v) && ISINT(w)) {
-          int ilow = 0, ihigh = INT_MAX;
+          ssize_t ilow = 0, ihigh = ssize_t_max;
           if (!_PyEval_SliceIndex(v, &ilow))
               return -1;
           if (!_PyEval_SliceIndex(w, &ihigh))
Index: libs/python/src/str.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/python/src/str.cpp,v
retrieving revision 1.10
retrieving revision 1.12
diff -u -b -w -u -r1.10 -r1.12
--- libs/python/src/str.cpp	10 Aug 2004 14:59:58 -0000	1.10
+++ boost_1_33_1/libs/python/src/str.cpp	26 Sep 2006 00:25:07 -0000	1.12
@@ -3,6 +3,7 @@
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 #include <boost/python/str.hpp>
 #include <boost/python/extract.hpp>
+#include <boost/python/ssize_t.hpp>
 
 namespace boost { namespace python { namespace detail {
 
@@ -21,10 +22,25 @@
   : object(detail::new_reference(::PyString_FromString(s)))
 {}
 
+namespace {
+
+    ssize_t str_size_as_py_ssize_t(std::size_t n)
+    {
+      if (n > ssize_t_max)
+      {
+          throw std::range_error("str size > ssize_t_max");
+      }
+      return static_cast<ssize_t>(n);
+    }
+
+} // namespace <anonymous>
+
 str_base::str_base(char const* start, char const* finish)
     : object(
         detail::new_reference(
-            ::PyString_FromStringAndSize(start, finish - start)
+            ::PyString_FromStringAndSize(
+                start, str_size_as_py_ssize_t(finish - start)
+            )
         )
     )
 {}
@@ -32,7 +48,9 @@
 str_base::str_base(char const* start, std::size_t length) // new str
     : object(
         detail::new_reference(
-            ::PyString_FromStringAndSize(start, length)
+            ::PyString_FromStringAndSize(
+                start, str_size_as_py_ssize_t(length)
+            )
         )
     )
 {}
Index: libs/python/src/object/class.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/python/src/object/class.cpp,v
retrieving revision 1.66
retrieving revision 1.70
diff -u -b -w -u -r1.66 -r1.70
--- libs/python/src/object/class.cpp	16 May 2005 03:31:12 -0000	1.66
+++ boost_1_33_1/libs/python/src/object/class.cpp	26 Sep 2006 00:25:07 -0000	1.70
@@ -20,6 +20,7 @@
 #include <boost/python/self.hpp>
 #include <boost/python/dict.hpp>
 #include <boost/python/str.hpp>
+#include <boost/python/ssize_t.hpp>
 #include <functional>
 #include <vector>
 #include <cstddef>
@@ -69,7 +70,7 @@
   } propertyobject;
 
   static PyObject *
-  static_data_descr_get(PyObject *self, PyObject *obj, PyObject * /*type*/)
+  static_data_descr_get(PyObject *self, PyObject * /*obj*/, PyObject * /*type*/)
   {
       propertyobject *gs = (propertyobject *)self;
 
@@ -77,7 +78,7 @@
   }
 
   static int
-  static_data_descr_set(PyObject *self, PyObject *obj, PyObject *value)
+  static_data_descr_set(PyObject *self, PyObject * /*obj*/, PyObject *value)
   {
       propertyobject *gs = (propertyobject *)self;
       PyObject *func, *res;
@@ -147,6 +148,14 @@
     0, // filled in with type_new           /* tp_new */
     0, // filled in with __PyObject_GC_Del  /* tp_free */
     (inquiry)type_is_gc,                    /* tp_is_gc */
+    0,                                      /* tp_bases */
+    0,                                      /* tp_mro */
+    0,                                      /* tp_cache */
+    0,                                      /* tp_subclasses */
+    0,                                      /* tp_weaklist */
+#if PYTHON_API_VERSION >= 1012
+    0                                       /* tp_del */
+#endif
 };
 
 namespace objects
@@ -243,6 +252,14 @@
     0, // filled in with type_new           /* tp_new */
     0, // filled in with __PyObject_GC_Del  /* tp_free */
     (inquiry)type_is_gc,                    /* tp_is_gc */
+    0,                                      /* tp_bases */
+    0,                                      /* tp_mro */
+    0,                                      /* tp_cache */
+    0,                                      /* tp_subclasses */
+    0,                                      /* tp_weaklist */
+#if PYTHON_API_VERSION >= 1012
+    0                                       /* tp_del */
+#endif
 };
 
 // Install the instance data for a C++ object into a Python instance
@@ -295,7 +312,7 @@
       }
 
       static PyObject *
-      instance_new(PyTypeObject* type_, PyObject* args, PyObject *kw)
+      instance_new(PyTypeObject* type_, PyObject* /*args*/, PyObject* /*kw*/)
       {
           // Attempt to find the __instance_size__ attribute. If not present, no problem.
           PyObject* d = type_->tp_dict;
@@ -340,14 +357,14 @@
 
 
   static PyGetSetDef instance_getsets[] = {
-      {"__dict__",  instance_get_dict,  instance_set_dict, NULL},
-      {0}
+      {"__dict__",  instance_get_dict,  instance_set_dict, NULL, 0},
+      {0, 0, 0, 0, 0}
   };
 
   
   static PyMemberDef instance_members[] = {
-      {"__weakref__", T_OBJECT, offsetof(instance<>, weakrefs), 0},
-      {0}
+      {"__weakref__", T_OBJECT, offsetof(instance<>, weakrefs), 0, 0},
+      {0, 0, 0, 0, 0}
   };
 
   static PyTypeObject class_type_object = {
@@ -390,7 +407,17 @@
       offsetof(instance<>,dict),              /* tp_dictoffset */
       0,                                      /* tp_init */
       PyType_GenericAlloc,                    /* tp_alloc */
-      instance_new                            /* tp_new */
+      instance_new,                           /* tp_new */
+      0,                                      /* tp_free */
+      0,                                      /* tp_is_gc */
+      0,                                      /* tp_bases */
+      0,                                      /* tp_mro */
+      0,                                      /* tp_cache */
+      0,                                      /* tp_subclasses */
+      0,                                      /* tp_weaklist */
+#if PYTHON_API_VERSION >= 1012
+      0                                       /* tp_del */
+#endif
   };
 
   BOOST_PYTHON_DECL type_handle class_type()
@@ -480,13 +507,14 @@
       // were declared, we'll use our class_type() as the single base
       // class.
       std::size_t const num_bases = (std::max)(num_types - 1, static_cast<std::size_t>(1));
-      handle<> bases(PyTuple_New(num_bases));
+      assert(num_bases <= ssize_t_max);
+      handle<> bases(PyTuple_New(static_cast<ssize_t>(num_bases)));
 
       for (std::size_t i = 1; i <= num_bases; ++i)
       {
           type_handle c = (i >= num_types) ? class_type() : get_class(types[i]);
           // PyTuple_SET_ITEM steals this reference
-          PyTuple_SET_ITEM(bases.get(), i - 1, upcast<PyObject>(c.release()));
+          PyTuple_SET_ITEM(bases.get(), static_cast<ssize_t>(i - 1), upcast<PyObject>(c.release()));
       }
 
       // Call the class metatype to create a new class
@@ -504,6 +532,10 @@
       if (scope().ptr() != Py_None)
           scope().attr(name) = result;
 
+      // For pickle. Will lead to informative error messages if pickling
+      // is not enabled.
+      result.attr("__reduce__") = object(make_instance_reduce_function());
+
       return result;
     }
   }
@@ -601,7 +633,6 @@
 
   void class_base::enable_pickling_(bool getstate_manages_dict)
   {
-      setattr("__reduce__", object(make_instance_reduce_function()));
       setattr("__safe_for_unpickling__", object(true));
       
       if (getstate_manages_dict)
Index: libs/python/src/object/function.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/python/src/object/function.cpp,v
retrieving revision 1.42
retrieving revision 1.50
diff -u -b -w -u -r1.42 -r1.50
--- libs/python/src/object/function.cpp	12 Mar 2005 02:58:42 -0000	1.42
+++ boost_1_33_1/libs/python/src/object/function.cpp	26 Sep 2006 00:25:07 -0000	1.50
@@ -3,7 +3,7 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/python/object/function.hpp>
+#include <boost/python/docstring_options.hpp>
 #include <boost/python/object/function_object.hpp>
 #include <boost/python/object/function_handle.hpp>
 #include <boost/python/errors.hpp>
@@ -14,8 +14,8 @@
 #include <boost/python/extract.hpp>
 #include <boost/python/tuple.hpp>
 #include <boost/python/list.hpp>
+#include <boost/python/ssize_t.hpp>
 
-#include <boost/python/detail/api_placeholder.hpp>
 #include <boost/python/detail/signature.hpp>
 #include <boost/mpl/vector/vector10.hpp>
 
@@ -28,6 +28,11 @@
 # include <cstdio>
 #endif
 
+namespace boost { namespace python {
+  volatile bool docstring_options::show_user_defined_ = true;
+  volatile bool docstring_options::show_signatures_ = true;
+}}
+
 namespace boost { namespace python { namespace objects { 
 
 py_function_impl_base::~py_function_impl_base()
@@ -60,7 +65,7 @@
             = max_arity > num_keywords ? max_arity - num_keywords : 0;
 
 
-        unsigned tuple_size = num_keywords ? max_arity : 0;
+        ssize_t tuple_size = num_keywords ? max_arity : 0;
         m_arg_names = object(handle<>(PyTuple_New(tuple_size)));
 
         if (num_keywords != 0)
@@ -154,7 +159,9 @@
                     else
                     {
                         // build a new arg tuple, will adjust its size later
-                        inner_args = handle<>(PyTuple_New(max_arity));
+                        assert(max_arity <= ssize_t_max);
+                        inner_args = handle<>(
+                            PyTuple_New(static_cast<ssize_t>(max_arity)));
 
                         // Fill in the positional arguments
                         for (std::size_t i = 0; i < n_unnamed_actual; ++i)
@@ -228,30 +235,12 @@
     return 0;
 }
 
-void function::argument_error(PyObject* args, PyObject* keywords) const
+object function::signature(bool show_return_type) const
 {
-    static handle<> exception(
-        PyErr_NewException("Boost.Python.ArgumentError", PyExc_TypeError, 0));
+    py_function const& impl = m_fn;
 
-    object message = "Python argument types in\n    %s.%s("
-        % make_tuple(this->m_namespace, this->m_name);
-    
-    list actual_args;
-    for (int i = 0; i < PyTuple_Size(args); ++i)
-    {
-        char const* name = PyTuple_GetItem(args, i)->ob_type->tp_name;
-        actual_args.append(str(name));
-    }
-    message += str(", ").join(actual_args);
-    message += ")\ndid not match C++ signature:\n    ";
-
-    list signatures;
-    for (function const* f = this; f; f = f->m_overloads.get())
-    {
-        py_function const& impl = f->m_fn;
-        
-        python::detail::signature_element const* s
-            = impl.signature() + 1; // skip over return type
+    python::detail::signature_element const* return_type = impl.signature();
+    python::detail::signature_element const* s = return_type + 1;
         
         list formal_params;
         if (impl.max_arity() == 0)
@@ -269,9 +258,9 @@
             if (s[n].lvalue)
                 param += " {lvalue}";
             
-            if (f->m_arg_names) // None or empty tuple will test false
+        if (m_arg_names) // None or empty tuple will test false
             {
-                object kv(f->m_arg_names[n]);
+            object kv(m_arg_names[n]);
                 if (kv)
                 {
                     char const* const fmt = len(kv) > 1 ? " %s=%r" : " %s";
@@ -282,12 +271,39 @@
             formal_params.append(param);
         }
 
-        signatures.append(
-            "%s(%s)" % make_tuple(f->m_name, str(", ").join(formal_params))
-            );
+    if (show_return_type)
+        return "%s(%s) -> %s" % make_tuple(
+            m_name, str(", ").join(formal_params), return_type->basename);
+    return "%s(%s)" % make_tuple(
+        m_name, str(", ").join(formal_params));
+}
+
+object function::signatures(bool show_return_type) const
+{
+    list result;
+    for (function const* f = this; f; f = f->m_overloads.get()) {
+        result.append(f->signature(show_return_type));
+    }
+    return result;
     }
 
-    message += str("\n    ").join(signatures);
+void function::argument_error(PyObject* args, PyObject* /*keywords*/) const
+{
+    static handle<> exception(
+        PyErr_NewException("Boost.Python.ArgumentError", PyExc_TypeError, 0));
+
+    object message = "Python argument types in\n    %s.%s("
+        % make_tuple(this->m_namespace, this->m_name);
+    
+    list actual_args;
+    for (ssize_t i = 0; i < PyTuple_Size(args); ++i)
+    {
+        char const* name = PyTuple_GetItem(args, i)->ob_type->tp_name;
+        actual_args.append(str(name));
+    }
+    message += str(", ").join(actual_args);
+    message += ")\ndid not match C++ signature:\n    ";
+    message += str("\n    ").join(signatures());
 
 #if BOOST_PYTHON_DEBUG_ERROR_MESSAGES
     std::printf("\n--------\n%s\n--------\n", extract<const char*>(message)());
@@ -392,6 +408,12 @@
 void function::add_to_namespace(
     object const& name_space, char const* name_, object const& attribute)
 {
+    add_to_namespace(name_space, name_, attribute, 0);
+}
+
+void function::add_to_namespace(
+    object const& name_space, char const* name_, object const& attribute, char const* doc)
+{
     str const name(name_);
     PyObject* const ns = name_space.ptr();
     
@@ -463,16 +485,11 @@
     PyErr_Clear();
     if (PyObject_SetAttr(ns, name.ptr(), attribute.ptr()) < 0)
         throw_error_already_set();
-}
 
-void function::add_to_namespace(
-    object const& name_space, char const* name_, object const& attribute, char const* doc)
-{
-    add_to_namespace(name_space, name_, attribute);
-    if (doc != 0)
+    object mutable_attribute(attribute);
+    if (doc != 0 && docstring_options::show_user_defined_)
     {
         // Accumulate documentation
-        object mutable_attribute(attribute);
         
         if (
             PyObject_HasAttrString(mutable_attribute.ptr(), "__doc__")
@@ -481,15 +498,30 @@
             mutable_attribute.attr("__doc__") += "\n\n";
             mutable_attribute.attr("__doc__") += doc;
         }
-        else
+        else {
             mutable_attribute.attr("__doc__") = doc;
     }
 }
 
+    if (docstring_options::show_signatures_)
+    {
+        if (   PyObject_HasAttrString(mutable_attribute.ptr(), "__doc__")
+            && mutable_attribute.attr("__doc__")) {
+            mutable_attribute.attr("__doc__") += "\n";
+        }
+        else {
+            mutable_attribute.attr("__doc__") = "";
+        }
+        function* f = downcast<function>(attribute.ptr());
+        mutable_attribute.attr("__doc__") += str("\n    ").join(make_tuple(
+          "C++ signature:", f->signature(true)));
+    }
+}
+
 BOOST_PYTHON_DECL void add_to_namespace(
     object const& name_space, char const* name, object const& attribute)
 {
-    function::add_to_namespace(name_space, name, attribute);
+    function::add_to_namespace(name_space, name, attribute, 0);
 }
 
 BOOST_PYTHON_DECL void add_to_namespace(
@@ -580,19 +612,19 @@
     // We add a dummy __class__ attribute in order to fool PyDoc into
     // treating these as built-in functions and scanning their
     // documentation
-    static PyObject* function_get_class(PyObject* op, void*)
+    static PyObject* function_get_class(PyObject* /*op*/, void*)
     {
         return python::incref(upcast<PyObject>(&PyCFunction_Type));
     }
 }
     
 static PyGetSetDef function_getsetlist[] = {
-    {"__name__", (getter)function_get_name, 0 },
-    {"func_name", (getter)function_get_name, 0 },
-    {"__class__", (getter)function_get_class, 0 },    // see note above
-    {"__doc__", (getter)function_get_doc, (setter)function_set_doc},
-    {"func_doc", (getter)function_get_doc, (setter)function_set_doc},
-    {NULL} /* Sentinel */
+    {"__name__", (getter)function_get_name, 0, 0, 0 },
+    {"func_name", (getter)function_get_name, 0, 0, 0 },
+    {"__class__", (getter)function_get_class, 0, 0, 0 },    // see note above
+    {"__doc__", (getter)function_get_doc, (setter)function_set_doc, 0, 0},
+    {"func_doc", (getter)function_get_doc, (setter)function_set_doc, 0, 0},
+    {NULL, 0, 0, 0, 0} /* Sentinel */
 };
 
 PyTypeObject function_type = {
@@ -634,8 +666,17 @@
     0, //offsetof(PyFunctionObject, func_dict),      /* tp_dictoffset */
     0,                                      /* tp_init */
     0,                                      /* tp_alloc */
-    0,
-    0                                       /* tp_new */
+    0,                                      /* tp_new */
+    0,                                      /* tp_free */
+    0,                                      /* tp_is_gc */
+    0,                                      /* tp_bases */
+    0,                                      /* tp_mro */
+    0,                                      /* tp_cache */
+    0,                                      /* tp_subclasses */
+    0,                                      /* tp_weaklist */
+#if PYTHON_API_VERSION >= 1012
+    0                                       /* tp_del */
+#endif
 };
 
 object function_object(
Index: boost/python/ssize_t.hpp
===================================================================
RCS file: boost/python/ssize_t.hpp
diff -N boost/python/ssize_t.hpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ boost_1_33_1/boost/python/ssize_t.hpp	26 Sep 2006 00:25:06 -0000	1.1
@@ -0,0 +1,29 @@
+// Copyright Ralf W. Grosse-Kunstleve & David Abrahams 2006.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_PYTHON_SSIZE_T_RWGK20060924_HPP
+# define BOOST_PYTHON_SSIZE_T_RWGK20060924_HPP
+
+# include <boost/python/detail/prefix.hpp>
+
+namespace boost { namespace python {
+
+#if PY_VERSION_HEX >= 0x02050000
+
+typedef Py_ssize_t ssize_t;
+ssize_t const ssize_t_max = PY_SSIZE_T_MAX;
+ssize_t const ssize_t_min = PY_SSIZE_T_MIN;
+
+#else
+
+typedef int ssize_t;
+ssize_t const ssize_t_max = INT_MAX;
+ssize_t const ssize_t_min = INT_MIN;
+
+#endif
+
+}} // namespace boost::python
+
+#endif // BOOST_PYTHON_SSIZE_T_RWGK20060924_HPP
--- boost/python/converter/registry.hpp	2005-05-16 05:30:56.000000000 +0200
+++ boost_1_33_1/boost/python/converter/registry.hpp	2006-12-03 14:39:02.000000000 +0100
@@ -10,6 +10,14 @@
 # include <boost/python/converter/constructor_function.hpp>
 # include <boost/python/converter/convertible_function.hpp>
 
+// undo a deliberately incompatible python2.5 API change
+#ifdef PyErr_Warn
+#undef PyErr_Warn
+extern "C" {
+	PyAPI_FUNC(int) PyErr_Warn(PyObject *, char *);
+}
+#endif
+
 namespace boost { namespace python { namespace converter {
 
 struct registration;
