From 6a5d6a88cd626ee563b344657faec2ceb62b7f59 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 19 Nov 2012 23:00:58 +0100 Subject: Fix crash when accessing the transaction code via post.xact.code using python ledger would abort with the following error message: TypeError: No Python class registered for C++ class boost::optional The changes pass a CallPolicy to make_getter when adding the transaction code property for python, so that the correct to_python conversion is made. For details see: http://www.boost.org/doc/libs/1_52_0/libs/python/doc/v2/faq.html#topythonconversionfailed --- src/py_xact.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/py_xact.cc') diff --git a/src/py_xact.cc b/src/py_xact.cc index 3d792c7b..96674207 100644 --- a/src/py_xact.cc +++ b/src/py_xact.cc @@ -119,8 +119,8 @@ void export_xact() .def("__str__", py_xact_to_string) .add_property("code", - make_getter(&xact_t::code), - make_setter(&xact_t::code)) + make_getter(&xact_t::code, return_value_policy()), + make_setter(&xact_t::code, return_value_policy())) .add_property("payee", make_getter(&xact_t::payee), make_setter(&xact_t::payee)) @@ -157,6 +157,8 @@ void export_xact() make_getter(&period_xact_t::period_string), make_setter(&period_xact_t::period_string)) ; + + register_optional_to_python(); } } // namespace ledger -- cgit v1.2.3