2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-28 07:22:31 +00:00

Fix bugs uncovered by Roman Yakovenko

[SVN r35410]
This commit is contained in:
Dave Abrahams
2006-09-29 02:09:13 +00:00
parent d42054f3a0
commit d5219979a4
2 changed files with 19 additions and 6 deletions

View File

@@ -29,8 +29,12 @@ struct implicit
static void construct(PyObject* obj, rvalue_from_python_stage1_data* data)
{
void* storage = ((rvalue_from_python_storage<Target>*)data)->storage.bytes;
arg_from_python<Source> get_source(obj);
bool convertible = get_source.convertible();
BOOST_ASSERT(convertible);
new (storage) Target(extract<Source>(obj)());
new (storage) Target(get_source());
// record successful construction
data->convertible = storage;

View File

@@ -169,7 +169,9 @@ namespace detail \
template <class L, class R> \
struct apply \
{ \
static inline PyObject* execute(L& l, R const& r) \
typedef typename unwrap_wrapper_<L>::type lhs; \
typedef typename unwrap_wrapper_<R>::type rhs; \
static PyObject* execute(lhs& l, rhs const& r) \
{ \
return detail::convert_result(expr); \
} \
@@ -183,7 +185,9 @@ namespace detail \
template <class L, class R> \
struct apply \
{ \
static inline PyObject* execute(R& r, L const& l) \
typedef typename unwrap_wrapper_<L>::type lhs; \
typedef typename unwrap_wrapper_<R>::type rhs; \
static PyObject* execute(rhs& r, lhs const& l) \
{ \
return detail::convert_result(expr); \
} \
@@ -271,8 +275,10 @@ namespace detail \
template <class L, class R> \
struct apply \
{ \
static inline PyObject* \
execute(back_reference<L&> l, R const& r) \
typedef typename unwrap_wrapper_<L>::type lhs; \
typedef typename unwrap_wrapper_<R>::type rhs; \
static PyObject* \
execute(back_reference<lhs&> l, rhs const& r) \
{ \
l.get() op r; \
return python::incref(l.source().ptr()); \
@@ -311,7 +317,8 @@ namespace detail \
template <class T> \
struct apply \
{ \
static PyObject* execute(T& x) \
typedef typename unwrap_wrapper_<T>::type self_t; \
static PyObject* execute(self_t& x) \
{ \
return detail::convert_result(op(x)); \
} \
@@ -339,6 +346,7 @@ BOOST_PYTHON_UNARY_OPERATOR(long, PyLong_FromLong, long_)
BOOST_PYTHON_UNARY_OPERATOR(float, double, float_)
BOOST_PYTHON_UNARY_OPERATOR(complex, std::complex<double>, complex_)
BOOST_PYTHON_UNARY_OPERATOR(str, lexical_cast<std::string>, str)
BOOST_PYTHON_UNARY_OPERATOR(repr, lexical_cast<std::string>, repr)
# undef BOOST_PYTHON_UNARY_OPERATOR
}} // namespace boost::python
@@ -350,6 +358,7 @@ using boost::python::self_ns::long_;
using boost::python::self_ns::float_;
using boost::python::self_ns::complex_;
using boost::python::self_ns::str;
using boost::python::self_ns::repr;
using boost::python::self_ns::pow;
# endif