From 8a90328ab7e1958d5e33f2961ad65c35682d9ce6 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 23 Jul 2020 20:20:26 +0200 Subject: proper ctx export --- common/pybindings.cc | 2 +- common/pybindings.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/pybindings.cc b/common/pybindings.cc index 49acb996..e1a7d313 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -145,7 +145,7 @@ PYBIND11_MODULE(MODULE_NAME, m) typedef std::unordered_map IdIdMap; typedef std::unordered_map> RegionMap; - py::class_>(m, "BaseCtx"); + py::class_(m, "BaseCtx"); auto loc_cls = py::class_(m, "Loc") .def(py::init()) diff --git a/common/pybindings.h b/common/pybindings.h index 4923c821..e143ddf4 100644 --- a/common/pybindings.h +++ b/common/pybindings.h @@ -45,7 +45,7 @@ template void python_export_global(const char *name, Tn &x) return; d = PyModule_GetDict(m); try { - py::object obj = py::cast(x); + py::object obj = py::cast(x, py::return_value_policy::reference); PyDict_SetItemString(d, name, obj.ptr()); } catch (py::error_already_set const &) { // Parse and output the exception -- cgit v1.2.3