Skip to content

Commit 93501af

Browse files
committed
always use ref (counting) for safety
[SVN r12393]
1 parent 078585d commit 93501af

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

include/boost/python/object/class.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ struct BOOST_PYTHON_DECL class_base : noncopyable
3838
// any bases.
3939
);
4040

41-
// Retrieve a pointer to the underlying object
42-
PyObject* object() const { return m_object.get(); }
41+
// Retrieve the underlying object
42+
ref object() const { return m_object; }
4343
private:
4444
ref m_object;
4545
};

include/boost/python/object/class_converters.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# include <boost/python/converter/class.hpp>
1010
# include <boost/python/object/class_wrapper.hpp>
1111
# include <boost/mpl/for_each.hpp>
12+
# include <boost/python/reference.hpp>
1213

1314
namespace boost { namespace python { namespace objects {
1415

@@ -20,7 +21,7 @@ struct class_converters
2021
{
2122
public: // member functions
2223
// Constructor takes the python class object associated with T
23-
class_converters(PyObject* python_class);
24+
class_converters(ref const& python_class);
2425

2526
private: // data members
2627
converter::class_unwrapper<Derived> m_unwrapper;
@@ -86,7 +87,7 @@ struct register_base_of
8687
};
8788

8889
template <class Derived, class Bases>
89-
class_converters<Derived,Bases>::class_converters(PyObject* type_object)
90+
class_converters<Derived,Bases>::class_converters(ref const& type_object)
9091
: m_wrapper(type_object)
9192
{
9293
// register all up/downcasts here

include/boost/python/object/class_wrapper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ template <class T>
1818
struct class_wrapper
1919
: converter::wrapper<T const&>
2020
{
21-
class_wrapper(PyObject* type_)
21+
class_wrapper(ref const& type_)
2222
: m_class_object(type_)
2323
{
2424
# ifndef NDEBUG

0 commit comments

Comments
 (0)