diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2019-11-06 15:26:15 +0200 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2019-11-06 17:16:23 +0200 |
commit | 77c1805d043b8b7692eb5aaae3732c4bd1e7af76 (patch) | |
tree | 7b3a06a2fbf921f232345ff566f401a760e47fd1 /py/pykms | |
parent | 04aabd4740d9915a72898d8a1c286e8288ec5983 (diff) |
pykmsbase: upgrade Blob __init__ to fix deprecation warning
Diffstat (limited to 'py/pykms')
-rw-r--r-- | py/pykms/pykmsbase.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp index 5f39faa..c039833 100644 --- a/py/pykms/pykmsbase.cpp +++ b/py/pykms/pykmsbase.cpp @@ -122,14 +122,14 @@ void init_pykmsbase(py::module &m) ; py::class_<Blob>(m, "Blob") - .def("__init__", [](Blob& instance, Card& card, py::buffer buf) { - py::buffer_info info = buf.request(); - if (info.ndim != 1) - throw std::runtime_error("Incompatible buffer dimension!"); - - new (&instance) Blob(card, info.ptr, info.size * info.itemsize); - }, - py::keep_alive<1, 3>()) // Keep Card alive until this is destructed + .def(py::init([](Card& card, py::buffer buf) { + py::buffer_info info = buf.request(); + if (info.ndim != 1) + throw std::runtime_error("Incompatible buffer dimension!"); + + return new Blob(card, info.ptr, info.size * info.itemsize); + }), + py::keep_alive<1, 2>()) // Keep Card alive until this is destructed .def_property_readonly("data", &Blob::data) |