Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66066 - in branches/release: boost/python boost/python/detail boost/python/object libs/python libs/python/example/tutorial libs/python/src/object libs/python/test
From: rwgk_at_[hidden]
Date: 2010-10-18 00:05:03


Author: rwgk
Date: 2010-10-18 00:04:52 EDT (Mon, 18 Oct 2010)
New Revision: 66066
URL: http://svn.boost.org/trac/boost/changeset/66066

Log:
merging current boost/python and libs/python from trunk into release branch
Properties modified:
   branches/release/boost/python/ (props changed)
   branches/release/libs/python/ (props changed)
Text files modified:
   branches/release/boost/python/detail/operator_id.hpp | 3 +++
   branches/release/boost/python/object/function.hpp | 2 ++
   branches/release/boost/python/object/make_instance.hpp | 3 ---
   branches/release/boost/python/operators.hpp | 6 +++++-
   branches/release/libs/python/example/tutorial/Jamroot | 8 ++++++++
   branches/release/libs/python/src/object/function.cpp | 15 +++++++++++++++
   branches/release/libs/python/test/pytype_function.py | 5 +++++
   7 files changed, 38 insertions(+), 4 deletions(-)

Modified: branches/release/boost/python/detail/operator_id.hpp
==============================================================================
--- branches/release/boost/python/detail/operator_id.hpp (original)
+++ branches/release/boost/python/detail/operator_id.hpp 2010-10-18 00:04:52 EDT (Mon, 18 Oct 2010)
@@ -53,6 +53,9 @@
     op_nonzero,
 #endif
     op_repr
+#if PY_VERSION_HEX >= 0x03000000
+ ,op_truediv
+#endif
 };
 
 }}} // namespace boost::python::detail

Modified: branches/release/boost/python/object/function.hpp
==============================================================================
--- branches/release/boost/python/object/function.hpp (original)
+++ branches/release/boost/python/object/function.hpp 2010-10-18 00:04:52 EDT (Mon, 18 Oct 2010)
@@ -39,6 +39,8 @@
     void doc(object const& x);
     
     object const& name() const;
+
+ object const& get_namespace() const { return m_namespace; }
     
  private: // helper functions
     object signature(bool show_return_type=false) const;

Modified: branches/release/boost/python/object/make_instance.hpp
==============================================================================
--- branches/release/boost/python/object/make_instance.hpp (original)
+++ branches/release/boost/python/object/make_instance.hpp 2010-10-18 00:04:52 EDT (Mon, 18 Oct 2010)
@@ -10,10 +10,7 @@
 # include <boost/python/converter/registered.hpp>
 # include <boost/python/detail/decref_guard.hpp>
 # include <boost/python/detail/none.hpp>
-# include <boost/type_traits/is_class.hpp>
 # include <boost/type_traits/is_union.hpp>
-# include <boost/mpl/assert.hpp>
-# include <boost/mpl/or.hpp>
 
 namespace boost { namespace python { namespace objects {
 

Modified: branches/release/boost/python/operators.hpp
==============================================================================
--- branches/release/boost/python/operators.hpp (original)
+++ branches/release/boost/python/operators.hpp 2010-10-18 00:04:52 EDT (Mon, 18 Oct 2010)
@@ -212,7 +212,11 @@
 BOOST_PYTHON_BINARY_OPERATOR(add, radd, +)
 BOOST_PYTHON_BINARY_OPERATOR(sub, rsub, -)
 BOOST_PYTHON_BINARY_OPERATOR(mul, rmul, *)
-BOOST_PYTHON_BINARY_OPERATOR(div, rdiv, /)
+#if PY_VERSION_HEX >= 0x03000000
+ BOOST_PYTHON_BINARY_OPERATOR(truediv, rtruediv, /)
+#else
+ BOOST_PYTHON_BINARY_OPERATOR(div, rdiv, /)
+#endif
 BOOST_PYTHON_BINARY_OPERATOR(mod, rmod, %)
 BOOST_PYTHON_BINARY_OPERATOR(lshift, rlshift, <<)
 BOOST_PYTHON_BINARY_OPERATOR(rshift, rrshift, >>)

Modified: branches/release/libs/python/example/tutorial/Jamroot
==============================================================================
--- branches/release/libs/python/example/tutorial/Jamroot (original)
+++ branches/release/libs/python/example/tutorial/Jamroot 2010-10-18 00:04:52 EDT (Mon, 18 Oct 2010)
@@ -26,6 +26,14 @@
 # source files after the colon separated by spaces.
 python-extension hello_ext : hello.cpp ;
 
+# Put the extension and Boost.Python DLL in the current directory, so
+# that running script by hand works.
+install convenient_copy
+ : hello_ext
+ : <install-dependencies>on <install-type>SHARED_LIB <install-type>PYTHON_EXTENSION
+ <location>.
+ ;
+
 # A little "rule" (function) to clean up the syntax of declaring tests
 # of these extension modules.
 local rule run-test ( test-name : sources + )

Modified: branches/release/libs/python/src/object/function.cpp
==============================================================================
--- branches/release/libs/python/src/object/function.cpp (original)
+++ branches/release/libs/python/src/object/function.cpp 2010-10-18 00:04:52 EDT (Mon, 18 Oct 2010)
@@ -670,11 +670,26 @@
     {
         return python::incref(upcast<PyObject>(&PyCFunction_Type));
     }
+
+ static PyObject* function_get_module(PyObject* op, void*)
+ {
+ function* f = downcast<function>(op);
+ object const& ns = f->get_namespace();
+ if (!ns.is_none()) {
+ return python::incref(ns.ptr());
+ }
+ PyErr_SetString(
+ PyExc_AttributeError, const_cast<char*>(
+ "Boost.Python function __module__ unknown."));
+ return 0;
+ }
 }
 
 static PyGetSetDef function_getsetlist[] = {
     {const_cast<char*>("__name__"), (getter)function_get_name, 0, 0, 0 },
     {const_cast<char*>("func_name"), (getter)function_get_name, 0, 0, 0 },
+ {const_cast<char*>("__module__"), (getter)function_get_module, 0, 0, 0 },
+ {const_cast<char*>("func_module"), (getter)function_get_module, 0, 0, 0 },
     {const_cast<char*>("__class__"), (getter)function_get_class, 0, 0, 0 }, // see note above
     {const_cast<char*>("__doc__"), (getter)function_get_doc, (setter)function_set_doc, 0, 0},
     {const_cast<char*>("func_doc"), (getter)function_get_doc, (setter)function_set_doc, 0, 0},

Modified: branches/release/libs/python/test/pytype_function.py
==============================================================================
--- branches/release/libs/python/test/pytype_function.py (original)
+++ branches/release/libs/python/test/pytype_function.py 2010-10-18 00:04:52 EDT (Mon, 18 Oct 2010)
@@ -7,6 +7,11 @@
>>> print func.__doc__.splitlines()[1]
 func( (A)arg1) -> A :
 
+>>> print func.__module__
+pytype_function_ext
+
+>>> print func.__name__
+func
 """
 def run(args = None):
     import sys


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk