@@ -21,8 +21,8 @@ namespace
2121 std::string type_name;
2222
2323 handle<> array_module;
24- object array_type;
25- object array_function;
24+ handle<> array_type;
25+ handle<> array_function;
2626
2727 void throw_load_failure ()
2828 {
@@ -56,12 +56,12 @@ namespace
5656
5757 if (type && PyType_Check (type))
5858 {
59- array_type = object ( detail::new_non_null_reference ( type) );
59+ array_type = handle<>( type);
6060 PyObject* function = ::PyObject_GetAttrString (module , const_cast <char *>(" array" ));
6161
6262 if (function && PyCallable_Check (function))
6363 {
64- array_function = object ( detail::new_reference ( function) );
64+ array_function = handle<>( function);
6565 state = succeeded;
6666 }
6767 }
@@ -78,10 +78,10 @@ namespace
7878 return false ;
7979 }
8080
81- object const & demand_array_function ()
81+ object demand_array_function ()
8282 {
8383 load (true );
84- return array_function;
84+ return object ( array_function) ;
8585 }
8686}
8787
@@ -99,29 +99,29 @@ namespace aux
9999 {
100100 if (!load (false ))
101101 return false ;
102- return ::PyObject_IsInstance (obj, array_type.ptr ());
102+ return ::PyObject_IsInstance (obj, array_type.get ());
103103 }
104104
105105 python::detail::new_non_null_reference
106106 array_object_manager_traits::adopt (PyObject* obj)
107107 {
108108 load (true );
109109 return detail::new_non_null_reference (
110- pytype_check (downcast<PyTypeObject>(array_type.ptr ()), obj));
110+ pytype_check (downcast<PyTypeObject>(array_type.get ()), obj));
111111 }
112112
113113
114114# define BOOST_PYTHON_AS_OBJECT (z, n, _ ) object(x##n)
115- # define BOOST_PP_LOCAL_MACRO (n ) \
116- array_base::array_base (BOOST_PP_ENUM_PARAMS(n, object const & x)) \
117- : object((load( true ), array_function) (BOOST_PP_ENUM_PARAMS(n, x))) \
115+ # define BOOST_PP_LOCAL_MACRO (n ) \
116+ array_base::array_base (BOOST_PP_ENUM_PARAMS(n, object const & x)) \
117+ : object(demand_array_function() (BOOST_PP_ENUM_PARAMS(n, x))) \
118118 {}
119119# define BOOST_PP_LOCAL_LIMITS (1 , 6 )
120120# include BOOST_PP_LOCAL_ITERATE()
121121# undef BOOST_PYTHON_AS_OBJECT
122122
123123 array_base::array_base (BOOST_PP_ENUM_PARAMS(7 , object const & x))
124- : object((load( true ), array_type )(BOOST_PP_ENUM_PARAMS(7 , x)))
124+ : object(demand_array_function( )(BOOST_PP_ENUM_PARAMS(7 , x)))
125125 {}
126126
127127 object array_base::argmax (long axis)
0 commit comments