summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/py_xact.cc6
-rw-r--r--test/regress/xact_code.dat3
-rw-r--r--test/regress/xact_code.py4
-rw-r--r--test/regress/xact_code_py.test3
4 files changed, 14 insertions, 2 deletions
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<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
diff --git a/test/regress/xact_code.dat b/test/regress/xact_code.dat
new file mode 100644
index 00000000..60956a23
--- /dev/null
+++ b/test/regress/xact_code.dat
@@ -0,0 +1,3 @@
+2012-11-10 (C0-d3) Payee
+ Assets:Checking € -12,45
+ Expenses:Expenditure
diff --git a/test/regress/xact_code.py b/test/regress/xact_code.py
new file mode 100644
index 00000000..64abb17d
--- /dev/null
+++ b/test/regress/xact_code.py
@@ -0,0 +1,4 @@
+import ledger
+
+for post in ledger.read_journal('test/regress/xact_code.dat').query('expenses'):
+ print post.xact.code
diff --git a/test/regress/xact_code_py.test b/test/regress/xact_code_py.test
new file mode 100644
index 00000000..c22158e0
--- /dev/null
+++ b/test/regress/xact_code_py.test
@@ -0,0 +1,3 @@
+test python test/regress/xact_code.py
+C0-d3
+end test