Skip to content

Commit d521997

Browse files
committed
Fix bugs uncovered by Roman Yakovenko
[SVN r35410]
1 parent d42054f commit d521997

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

include/boost/python/converter/implicit.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ struct implicit
2929
static void construct(PyObject* obj, rvalue_from_python_stage1_data* data)
3030
{
3131
void* storage = ((rvalue_from_python_storage<Target>*)data)->storage.bytes;
32+
33+
arg_from_python<Source> get_source(obj);
34+
bool convertible = get_source.convertible();
35+
BOOST_ASSERT(convertible);
3236

33-
new (storage) Target(extract<Source>(obj)());
37+
new (storage) Target(get_source());
3438

3539
// record successful construction
3640
data->convertible = storage;

include/boost/python/operators.hpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ namespace detail \
169169
template <class L, class R> \
170170
struct apply \
171171
{ \
172-
static inline PyObject* execute(L& l, R const& r) \
172+
typedef typename unwrap_wrapper_<L>::type lhs; \
173+
typedef typename unwrap_wrapper_<R>::type rhs; \
174+
static PyObject* execute(lhs& l, rhs const& r) \
173175
{ \
174176
return detail::convert_result(expr); \
175177
} \
@@ -183,7 +185,9 @@ namespace detail \
183185
template <class L, class R> \
184186
struct apply \
185187
{ \
186-
static inline PyObject* execute(R& r, L const& l) \
188+
typedef typename unwrap_wrapper_<L>::type lhs; \
189+
typedef typename unwrap_wrapper_<R>::type rhs; \
190+
static PyObject* execute(rhs& r, lhs const& l) \
187191
{ \
188192
return detail::convert_result(expr); \
189193
} \
@@ -271,8 +275,10 @@ namespace detail \
271275
template <class L, class R> \
272276
struct apply \
273277
{ \
274-
static inline PyObject* \
275-
execute(back_reference<L&> l, R const& r) \
278+
typedef typename unwrap_wrapper_<L>::type lhs; \
279+
typedef typename unwrap_wrapper_<R>::type rhs; \
280+
static PyObject* \
281+
execute(back_reference<lhs&> l, rhs const& r) \
276282
{ \
277283
l.get() op r; \
278284
return python::incref(l.source().ptr()); \
@@ -311,7 +317,8 @@ namespace detail \
311317
template <class T> \
312318
struct apply \
313319
{ \
314-
static PyObject* execute(T& x) \
320+
typedef typename unwrap_wrapper_<T>::type self_t; \
321+
static PyObject* execute(self_t& x) \
315322
{ \
316323
return detail::convert_result(op(x)); \
317324
} \
@@ -339,6 +346,7 @@ BOOST_PYTHON_UNARY_OPERATOR(long, PyLong_FromLong, long_)
339346
BOOST_PYTHON_UNARY_OPERATOR(float, double, float_)
340347
BOOST_PYTHON_UNARY_OPERATOR(complex, std::complex<double>, complex_)
341348
BOOST_PYTHON_UNARY_OPERATOR(str, lexical_cast<std::string>, str)
349+
BOOST_PYTHON_UNARY_OPERATOR(repr, lexical_cast<std::string>, repr)
342350
# undef BOOST_PYTHON_UNARY_OPERATOR
343351

344352
}} // namespace boost::python
@@ -350,6 +358,7 @@ using boost::python::self_ns::long_;
350358
using boost::python::self_ns::float_;
351359
using boost::python::self_ns::complex_;
352360
using boost::python::self_ns::str;
361+
using boost::python::self_ns::repr;
353362
using boost::python::self_ns::pow;
354363
# endif
355364

0 commit comments

Comments
 (0)