From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric-Emmanuel=20PICCA?= Date: Tue, 28 May 2013 14:24:36 +0200 Subject: fix from upstream python unsafe here the upstream bug report: https://sourceforge.net/p/tango-cs/bugs/551/ --- src/server/device_class.cpp | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/server/device_class.cpp b/src/server/device_class.cpp index 4af89ba..c479737 100644 --- a/src/server/device_class.cpp +++ b/src/server/device_class.cpp @@ -175,17 +175,35 @@ void CppDeviceClassWrap::init_class() signal_handler_defined = is_method_defined(m_self, "signal_handler"); } + + + + + + + void CppDeviceClassWrap::attribute_factory(std::vector &att_list) { // // make sure we pass the same vector object to the python method // + AutoPythonGIL python_guard; + object py_att_list( - handle<>( - to_python_indirect< - std::vector, - detail::make_reference_holder>()(att_list))); - CALL_DEVCLASS_METHOD_VARGS(_DeviceClass__attribute_factory, py_att_list) + handle<>( + to_python_indirect< + std::vector, + detail::make_reference_holder>()(att_list))); + + try + { + boost::python::call_method(m_self, "_DeviceClass__attribute_factory", + py_att_list); + } + catch(boost::python::error_already_set &eas) + { + handle_python_exception(eas); + } } void CppDeviceClassWrap::command_factory() @@ -198,12 +216,23 @@ void CppDeviceClassWrap::device_name_factory(std::vector &dev_list) // // make sure we pass the same vector object to the python method // + AutoPythonGIL python_guard; + object py_dev_list( handle<>( to_python_indirect< std::vector, detail::make_reference_holder>()(dev_list))); - CALL_DEVCLASS_METHOD_VARGS(device_name_factory, py_dev_list); + + try + { + boost::python::call_method(m_self, "device_name_factory", + py_dev_list); + } + catch(boost::python::error_already_set &eas) + { + handle_python_exception(eas); + } } void CppDeviceClassWrap::device_factory(const Tango::DevVarStringArray *dev_list)