Merge pull request #108 from afh/pull/python_xact_code

Fix crash when accessing the transaction code via post.xact.code using python
This commit is contained in:
John Wiegley 2012-11-19 14:27:44 -08:00
commit b74e257817
4 changed files with 14 additions and 2 deletions

View file

@ -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<return_by_value>()),
make_setter(&xact_t::code, return_value_policy<return_by_value>()))
.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<std::string>();
}
} // namespace ledger

View file

@ -0,0 +1,3 @@
2012-11-10 (C0-d3) Payee
Assets:Checking € -12,45
Expenses:Expenditure

View file

@ -0,0 +1,4 @@
import ledger
for post in ledger.read_journal('test/regress/xact_code.dat').query('expenses'):
print post.xact.code

View file

@ -0,0 +1,3 @@
test python test/regress/xact_code.py
C0-d3
end test