From 4c2927ca46b30441b3b2cf212a5c32624334bbae Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 5 Apr 2011 16:39:36 +0000 Subject: [PATCH 01/15] boost/libs/python/doc/PyConDC_2003: removing $Date$ and $Revision$ so they do not create noise on each merge to the release branch [SVN r71003] --- doc/PyConDC_2003/bpl_mods.txt | 1 - doc/PyConDC_2003/default.css | 2 -- 2 files changed, 3 deletions(-) diff --git a/doc/PyConDC_2003/bpl_mods.txt b/doc/PyConDC_2003/bpl_mods.txt index 299e71b8..d42f00f8 100644 --- a/doc/PyConDC_2003/bpl_mods.txt +++ b/doc/PyConDC_2003/bpl_mods.txt @@ -27,7 +27,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Somerville, MA 02143 :Contact: dave@boost-consulting.com :organization: `Boost Consulting`_ -:date: $Date$ :status: This is a "work in progress" :version: 1 :copyright: Copyright David Abrahams 2002. All rights reserved diff --git a/doc/PyConDC_2003/default.css b/doc/PyConDC_2003/default.css index 6a1adb08..f8109bbd 100644 --- a/doc/PyConDC_2003/default.css +++ b/doc/PyConDC_2003/default.css @@ -1,8 +1,6 @@ /* :Author: David Goodger :Contact: goodger@users.sourceforge.net -:date: $Date$ -:version: $Revision$ :copyright: This stylesheet has been placed in the public domain. boostinspect:nolicense From a11a3f9f76de5979e3e18de8b6453b8962eccb11 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 6 Apr 2011 21:32:59 +0000 Subject: [PATCH 02/15] libs/python/src/converter/builtin_converters.cpp: Python 3.2 compatibility, based on patch by Matthew Bradbury, fixes issue #4994 [SVN r71050] --- src/converter/builtin_converters.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/converter/builtin_converters.cpp b/src/converter/builtin_converters.cpp index c9d6bcbf..19f0126c 100644 --- a/src/converter/builtin_converters.cpp +++ b/src/converter/builtin_converters.cpp @@ -431,7 +431,10 @@ namespace if (!result.empty()) { int err = PyUnicode_AsWideChar( - (PyUnicodeObject *)intermediate +#if PY_VERSION_HEX < 0x03020000 + (PyUnicodeObject *) +#endif + intermediate , &result[0] , result.size()); From 09dc86f5f2a54ac721f04e303828bd9c0ed88b50 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 26 May 2011 00:21:33 +0000 Subject: [PATCH 03/15] libs/python/test/Jamfile.v2: patch provided by Niklas Angare (Ticket #5565) [SVN r72173] --- test/Jamfile.v2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 876fde12..4377a9a0 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -3,11 +3,18 @@ # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) import python ; +import os ; + +if [ os.name ] = QNXNTO +{ + lib socket ; +} use-project /boost/python : ../build ; project /boost/python/test : requirements gcc:-Wextra + QNXNTO:socket ; local PY = ; From f441ec7dfdb36e8dd81298b5e535f51f36249da8 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 26 May 2011 01:50:32 +0000 Subject: [PATCH 04/15] libs/python/test/Jamfile.v2: implementing suggestions by Steven Watanabe (thanks!) [SVN r72174] --- test/Jamfile.v2 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 4377a9a0..bbdab714 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -5,16 +5,13 @@ import python ; import os ; -if [ os.name ] = QNXNTO -{ - lib socket ; -} +lib socket ; use-project /boost/python : ../build ; project /boost/python/test : requirements gcc:-Wextra - QNXNTO:socket + QNXNTO:socket ; local PY = ; From 201c1004226038686850bafb3ef8e85e91cfa98a Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 26 May 2011 04:09:40 +0000 Subject: [PATCH 05/15] libs/python/test/Jamfile.v2: correction, by Steven Watanabe [SVN r72175] --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index bbdab714..55241880 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -11,7 +11,7 @@ use-project /boost/python : ../build ; project /boost/python/test : requirements gcc:-Wextra - QNXNTO:socket + qnxnto:socket ; local PY = ; From 4df7f1c247cce348df0951c0caa455c515e992bf Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 27 May 2011 17:11:44 +0000 Subject: [PATCH 06/15] libs/python/doc/tutorial/doc/tutorial.qbk: fixing small oversight (issue #5574) [SVN r72220] --- doc/tutorial/doc/html/index.html | 2 +- doc/tutorial/doc/tutorial.qbk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/tutorial/doc/html/index.html b/doc/tutorial/doc/html/index.html index d63480c1..6e43c390 100644 --- a/doc/tutorial/doc/html/index.html +++ b/doc/tutorial/doc/html/index.html @@ -124,7 +124,7 @@

>>> import hello_ext
->>> print hello.greet()
+>>> print hello_ext.greet()
 hello, world
 

diff --git a/doc/tutorial/doc/tutorial.qbk b/doc/tutorial/doc/tutorial.qbk index f1697fae..94ecc55b 100644 --- a/doc/tutorial/doc/tutorial.qbk +++ b/doc/tutorial/doc/tutorial.qbk @@ -62,7 +62,7 @@ resulting DLL is now visible to Python. Here's a sample Python session: [python] >>> import hello_ext - >>> print hello.greet() + >>> print hello_ext.greet() hello, world [c++] From 8e703e95692bd3ef130835fef11fd3515222a07f Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 2 Jun 2011 17:04:43 +0000 Subject: [PATCH 07/15] libs/python/src: patches by Bogdan Opanchuk (trac #5590) [SVN r72349] --- src/converter/builtin_converters.cpp | 2 ++ src/converter/from_python.cpp | 5 +---- src/object/class.cpp | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/converter/builtin_converters.cpp b/src/converter/builtin_converters.cpp index 19f0126c..c7c95ea8 100644 --- a/src/converter/builtin_converters.cpp +++ b/src/converter/builtin_converters.cpp @@ -366,7 +366,9 @@ namespace static PyTypeObject const* get_pytype() { return &PyFloat_Type;} }; +#if PY_VERSION_HEX >= 0x03000000 unaryfunc py_unicode_as_string_unaryfunc = PyUnicode_AsUTF8String; +#endif // A SlotPolicy for extracting C++ strings from Python objects. struct string_rvalue_from_python diff --git a/src/converter/from_python.cpp b/src/converter/from_python.cpp index 0af47609..9678be1c 100644 --- a/src/converter/from_python.cpp +++ b/src/converter/from_python.cpp @@ -44,11 +44,8 @@ BOOST_PYTHON_DECL rvalue_from_python_stage1_data rvalue_from_python_stage1( // First check to see if it's embedded in an extension class // instance, as a special case. data.convertible = objects::find_instance_impl(source, converters.target_type, converters.is_shared_ptr); - if (data.convertible) - { data.construct = 0; - } - else + if (!data.convertible) { for (rvalue_from_python_chain const* chain = converters.rvalue_chain; chain != 0; diff --git a/src/object/class.cpp b/src/object/class.cpp index 3f818d82..aeef688e 100644 --- a/src/object/class.cpp +++ b/src/object/class.cpp @@ -76,11 +76,11 @@ extern "C" static int property_init(PyObject *self, PyObject *args, PyObject *kwds) { PyObject *get = NULL, *set = NULL, *del = NULL, *doc = NULL; - static char *kwlist[] = {"fget", "fset", "fdel", "doc", 0}; + static const char *kwlist[] = {"fget", "fset", "fdel", "doc", 0}; propertyobject *prop = (propertyobject *)self; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO:property", - kwlist, &get, &set, &del, &doc)) + const_cast(kwlist), &get, &set, &del, &doc)) return -1; if (get == Py_None) From 1212a147390338ddbc78a5626dfcfa1990e71eea Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 4 Jun 2011 09:50:27 +0000 Subject: [PATCH 08/15] boost/python/override.hpp: trac issue #4101 [SVN r72384] --- include/boost/python/override.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 include/boost/python/override.hpp diff --git a/include/boost/python/override.hpp b/include/boost/python/override.hpp old mode 100755 new mode 100644 index d5a95b83..39714257 --- a/include/boost/python/override.hpp +++ b/include/boost/python/override.hpp @@ -77,7 +77,7 @@ namespace detail template T unchecked(type* = 0) { - return extract(m_obj)(); + return extract(m_obj.get())(); } private: mutable handle<> m_obj; From 3e409f9a87bfb329840431fc5539b35b7db297b7 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 14 Jun 2011 23:23:33 +0000 Subject: [PATCH 09/15] boost/python/slice.hpp: correct long-standing spelling error; affects interface; keeping old interface for backward compatibility [SVN r72602] --- doc/v2/slice.html | 14 +++++++------- include/boost/python/slice.hpp | 16 +++++++++++++--- test/slice.cpp | 8 ++++---- test/slice.py | 12 ++++++------ 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/doc/v2/slice.html b/doc/v2/slice.html index 8831d971..fb6b47c7 100644 --- a/doc/v2/slice.html +++ b/doc/v2/slice.html @@ -85,7 +85,7 @@ namespace boost { namespace python object stop(); object step(); - // The return type of slice::get_indicies() + // The return type of slice::get_indices() template <typename RandomAccessIterator> struct range { @@ -96,7 +96,7 @@ namespace boost { namespace python template <typename RandomAccessIterator> range<RandomAccessIterator> - get_indicies( + get_indices( RandomAccessIterator const& begin, RandomAccessIterator const& end); }; @@ -164,7 +164,7 @@ slice object, but in practice they are usually integers.

 template <typename RandomAccessIterator>
 slice::range<RandomAccessIterator>
-slice::get_indicies( 
+slice::get_indices( 
     RandomAccessIterator const& begin, 
     RandomAccessIterator const& end) const;
 
@@ -173,8 +173,8 @@ slice::get_indicies( Iterators that form a half-open range.
Effects: Create a RandomAccessIterator pair that defines a fully-closed range within the [begin,end) range of its arguments.  -This function translates this slice's indicies while accounting for the -effects of any PyNone or negative indicies, and non-singular step sizes.
+This function translates this slice's indices while accounting for the +effects of any PyNone or negative indices, and non-singular step sizes.
Returns: a slice::range that has been initialized with a non-zero value of step and a pair of RandomAccessIterators that point within the range of this functions @@ -182,7 +182,7 @@ arguments and define a closed interval.
Throws: Raises a Python TypeError exception if any of this slice's arguments are neither references to PyNone nor convertible to int.  Throws std::invalid_argument if the resulting range would be empty.  You -should always wrap calls to slice::get_indicies() +should always wrap calls to slice::get_indices() within try { ...; } catch (std::invalid_argument) {} to handle this case and take appropriate action.
Rationale: closed-interval: If @@ -221,7 +221,7 @@ double partial_sum(std::vector<double> const& Foo, const slice index) { slice::range<std::vector<double>::const_iterator> bounds; try { - bounds = index.get_indicies<>(Foo.begin(), Foo.end()); + bounds = index.get_indices<>(Foo.begin(), Foo.end()); } catch (std::invalid_argument) { return 0.0; diff --git a/include/boost/python/slice.hpp b/include/boost/python/slice.hpp index 382ceb81..4fc62418 100644 --- a/include/boost/python/slice.hpp +++ b/include/boost/python/slice.hpp @@ -30,7 +30,7 @@ namespace detail // that created this slice, than that parameter is None here, and compares // equal to a default-constructed boost::python::object. // If a user-defined type wishes to support slicing, then support for the - // special meaning associated with negative indicies is up to the user. + // special meaning associated with negative indices is up to the user. object start() const; object stop() const; object step() const; @@ -63,7 +63,7 @@ class slice : public detail::slice_base // The following algorithm is intended to automate the process of // determining a slice range when you want to fully support negative - // indicies and non-singular step sizes. Its functionallity is simmilar to + // indices and non-singular step sizes. Its functionallity is simmilar to // PySlice_GetIndicesEx() in the Python/C API, but tailored for C++ users. // This template returns a slice::range struct that, when used in the // following iterative loop, will traverse a slice of the function's @@ -110,7 +110,7 @@ class slice : public detail::slice_base template slice::range - get_indicies( const RandomAccessIterator& begin, + get_indices( const RandomAccessIterator& begin, const RandomAccessIterator& end) const { // This is based loosely on PySlice_GetIndicesEx(), but it has been @@ -240,6 +240,16 @@ class slice : public detail::slice_base return ret; } + + // Incorrect spelling. DO NOT USE. Only here for backward compatibility. + // Corrected 2011-06-14. + template + slice::range + get_indicies( const RandomAccessIterator& begin, + const RandomAccessIterator& end) const + { + get_indices(begin, end); + } public: // This declaration, in conjunction with the specialization of diff --git a/test/slice.cpp b/test/slice.cpp index 032bf7cf..5072d7f7 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -98,9 +98,9 @@ bool accept_slice( slice) { return true; } #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1400)) \ || BOOST_WORKAROUND( BOOST_INTEL_WIN, == 710) -int check_slice_get_indicies(slice index); +int check_slice_get_indices(slice index); #endif -int check_slice_get_indicies( +int check_slice_get_indices( #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) const #endif @@ -116,7 +116,7 @@ int check_slice_get_indicies( slice::range::iterator> bounds; try { - bounds = index.get_indicies(coll.begin(), coll.end()); + bounds = index.get_indices(coll.begin(), coll.end()); } catch (std::invalid_argument) { return 0; @@ -136,5 +136,5 @@ BOOST_PYTHON_MODULE(slice_ext) def( "accept_slice", accept_slice); def( "check_numeric_array_rich_slice", check_numeric_array_rich_slice); def( "check_string_rich_slice", check_string_rich_slice); - def( "check_slice_get_indicies", check_slice_get_indicies); + def( "check_slice_get_indices", check_slice_get_indices); } diff --git a/test/slice.py b/test/slice.py index c281845b..95f4883b 100644 --- a/test/slice.py +++ b/test/slice.py @@ -37,17 +37,17 @@ test passed ... print 1 ... 1 ->>> check_slice_get_indicies( slice(None)) +>>> check_slice_get_indices( slice(None)) 0 ->>> check_slice_get_indicies( slice(2,-2)) +>>> check_slice_get_indices( slice(2,-2)) 0 ->>> check_slice_get_indicies( slice(2, None, 2)) +>>> check_slice_get_indices( slice(2, None, 2)) 5 ->>> check_slice_get_indicies( slice(2, None, -1)) +>>> check_slice_get_indices( slice(2, None, -1)) -12 ->>> check_slice_get_indicies( slice( 20, None)) +>>> check_slice_get_indices( slice( 20, None)) 0 ->>> check_slice_get_indicies( slice( -2, -5, -2)) +>>> check_slice_get_indices( slice( -2, -5, -2)) 6 """ From f1efb481c3274320f16cfdeae0fe6cf3efcdbb7a Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 24 Jun 2011 21:27:40 +0000 Subject: [PATCH 10/15] boost/python.hpp: include slice.hpp (trac issue 5639) [SVN r72745] --- include/boost/python.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/python.hpp b/include/boost/python.hpp index ae49abaf..1b1ffb65 100644 --- a/include/boost/python.hpp +++ b/include/boost/python.hpp @@ -61,6 +61,7 @@ # include # include # include +# include # include # include # include From 211c90ae0f04b08010d970b74c106d9b4ece41dd Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 24 Jun 2011 22:16:06 +0000 Subject: [PATCH 11/15] boost/python.hpp: adding two more missing includes [SVN r72746] --- include/boost/python.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/python.hpp b/include/boost/python.hpp index 1b1ffb65..11067c17 100644 --- a/include/boost/python.hpp +++ b/include/boost/python.hpp @@ -53,6 +53,7 @@ # include # include # include +# include # include # include # include @@ -63,6 +64,7 @@ # include # include # include +# include # include # include # include From 302fee14b052abcf40be4fe746a1f00fd6ccaaa6 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 25 Jun 2011 01:27:17 +0000 Subject: [PATCH 12/15] libs/python/doc/v2/with_custodian_and_ward.html: correcting minor typo [SVN r72748] --- doc/v2/with_custodian_and_ward.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/v2/with_custodian_and_ward.html b/doc/v2/with_custodian_and_ward.html index 5f03b3b1..b8e2a498 100644 --- a/doc/v2/with_custodian_and_ward.html +++ b/doc/v2/with_custodian_and_ward.html @@ -91,7 +91,7 @@

Introduction -

This header provides faciliites for establishing a lifetime + This header provides facilities for establishing a lifetime dependency between two of a function's Python argument or result objects. The ward object will not be destroyed until after the custodian as long as the custodian object supports Date: Tue, 23 Aug 2011 16:24:48 +0000 Subject: [PATCH 13/15] boost/python/class.hpp: commenting out assertion, resolves trac #5803 [SVN r74020] --- include/boost/python/class.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index 0ec86f43..253667bb 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -138,7 +138,8 @@ namespace detail static void must_be_derived_class_member(Default const&) { - typedef typename assertion > >::failed test0; + // https://svn.boost.org/trac/boost/ticket/5803 + //typedef typename assertion > >::failed test0; # if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) typedef typename assertion >::failed test1; # endif From 838f44c0500706836088901d3bcf2129ec74e9ac Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 23 Aug 2011 16:42:15 +0000 Subject: [PATCH 14/15] boost/python: fixing long-standing mis-spelling, resolves trac #5805 [SVN r74021] --- include/boost/python/detail/make_keyword_range_fn.hpp | 2 +- include/boost/python/object/class_metadata.hpp | 6 +++--- include/boost/python/object/make_holder.hpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) mode change 100755 => 100644 include/boost/python/object/class_metadata.hpp diff --git a/include/boost/python/detail/make_keyword_range_fn.hpp b/include/boost/python/detail/make_keyword_range_fn.hpp index 634bbb99..c4795cf8 100644 --- a/include/boost/python/detail/make_keyword_range_fn.hpp +++ b/include/boost/python/detail/make_keyword_range_fn.hpp @@ -57,7 +57,7 @@ object make_keyword_range_constructor( , Holder* = 0 , ArgList* = 0, Arity* = 0) { -#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SYGNATURES_PROPER_INIT_SELF_TYPE) +#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE) python_class::register_(); #endif return detail::make_keyword_range_function( diff --git a/include/boost/python/object/class_metadata.hpp b/include/boost/python/object/class_metadata.hpp old mode 100755 new mode 100644 index 0738bbe3..155ae35d --- a/include/boost/python/object/class_metadata.hpp +++ b/include/boost/python/object/class_metadata.hpp @@ -238,7 +238,7 @@ struct class_metadata // inline static void maybe_register_pointer_to_python(...) {} -#ifndef BOOST_PYTHON_NO_PY_SYGNATURES +#ifndef BOOST_PYTHON_NO_PY_SIGNATURES inline static void maybe_register_pointer_to_python(void*,void*,mpl::true_*) { objects::copy_class_object(python::type_id(), python::type_id >()); @@ -255,7 +255,7 @@ struct class_metadata , make_ptr_instance > >() ); -#ifndef BOOST_PYTHON_NO_PY_SYGNATURES +#ifndef BOOST_PYTHON_NO_PY_SIGNATURES // explicit qualification of type_id makes msvc6 happy objects::copy_class_object(python::type_id(), python::type_id()); #endif @@ -270,7 +270,7 @@ struct class_metadata inline static void maybe_register_class_to_python(T2*, mpl::false_) { python::detail::force_instantiate(class_cref_wrapper >()); -#ifndef BOOST_PYTHON_NO_PY_SYGNATURES +#ifndef BOOST_PYTHON_NO_PY_SIGNATURES // explicit qualification of type_id makes msvc6 happy objects::copy_class_object(python::type_id(), python::type_id()); #endif diff --git a/include/boost/python/object/make_holder.hpp b/include/boost/python/object/make_holder.hpp index eb3c603d..0d54dd9f 100644 --- a/include/boost/python/object/make_holder.hpp +++ b/include/boost/python/object/make_holder.hpp @@ -12,7 +12,7 @@ # include # include -#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SYGNATURES_PROPER_INIT_SELF_TYPE) +#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE) # include #endif @@ -81,7 +81,7 @@ struct make_holder # endif static void execute( -#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SYGNATURES_PROPER_INIT_SELF_TYPE) +#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE) boost::python::detail::python_class *p #else PyObject *p From 8449c34948a0bca4be22f1ecbada3d40f16b2db5 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 8 Sep 2011 21:27:10 +0000 Subject: [PATCH 15/15] libs/python/src/object/function.cpp: apply patch by Matthew Bradbury (trac #4259) [SVN r74321] --- src/object/function.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/object/function.cpp b/src/object/function.cpp index 9328e014..5c59cc77 100644 --- a/src/object/function.cpp +++ b/src/object/function.cpp @@ -433,23 +433,23 @@ void function::add_to_namespace( if (attribute.ptr()->ob_type == &function_type) { function* new_func = downcast(attribute.ptr()); - PyObject* dict = 0; + handle<> dict; #if PY_VERSION_HEX < 0x03000000 // Old-style class gone in Python 3 if (PyClass_Check(ns)) - dict = ((PyClassObject*)ns)->cl_dict; + dict = handle<>(borrowed(((PyClassObject*)ns)->cl_dict)); else #endif if (PyType_Check(ns)) - dict = ((PyTypeObject*)ns)->tp_dict; + dict = handle<>(borrowed(((PyTypeObject*)ns)->tp_dict)); else - dict = PyObject_GetAttrString(ns, const_cast("__dict__")); + dict = handle<>(PyObject_GetAttrString(ns, const_cast("__dict__"))); if (dict == 0) throw_error_already_set(); - handle<> existing(allow_null(::PyObject_GetItem(dict, name.ptr()))); + handle<> existing(allow_null(::PyObject_GetItem(dict.get(), name.ptr()))); if (existing) {