summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pyutils.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/pyutils.h b/src/pyutils.h
index 6c9675b7..7bc0d0af 100644
--- a/src/pyutils.h
+++ b/src/pyutils.h
@@ -88,13 +88,14 @@ struct register_optional_to_python : public boost::noncopyable
{
using namespace boost::python::converter;
- void * const storage =
- reinterpret_cast<rvalue_from_python_storage<T> *>(data)->storage.bytes;
+ const T value = typename boost::python::extract<T>(source);
- if (data->convertible == source) // == None
+ void * storage = ((rvalue_from_python_storage<boost::optional<T>>*) data)->storage.bytes;
+
+ if (source == Py_None) // == None
new (storage) boost::optional<T>(); // A Boost uninitialized value
else
- new (storage) boost::optional<T>(*reinterpret_cast<T *>(data->convertible));
+ new (storage) boost::optional<T>(value);
data->convertible = storage;
}