[pytango] 312/483: fixes #527
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:54 UTC 2017
This is an automated email from the git hooks/post-receive script.
sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.
commit f72f50bf7fa2c0338c5ccf4d760c57e0e9d817af
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Fri Nov 22 09:30:41 2013 +0000
fixes #527
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@24332 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
src/boost/cpp/fast_from_py.h | 18 +++++++++++++++---
src/boost/cpp/server/attribute.cpp | 2 +-
src/boost/cpp/server/wattribute.cpp | 9 ++++++---
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/src/boost/cpp/fast_from_py.h b/src/boost/cpp/fast_from_py.h
index d7f70b1..4329aae 100644
--- a/src/boost/cpp/fast_from_py.h
+++ b/src/boost/cpp/fast_from_py.h
@@ -135,7 +135,7 @@ struct from_py<tangoTypeConst> \
PyErr_SetString(PyExc_TypeError, "Expecting a numeric type," \
" but it is not. If you use a numpy type instead of" \
" python core types, then it must exactly match (ex:" \
- " numpy.int32 for PyTango.DevLong (1))"); \
+ " numpy.int32 for PyTango.DevLong)"); \
boost::python::throw_error_already_set(); \
} \
} \
@@ -155,6 +155,18 @@ struct from_py<tangoTypeConst> \
#endif // !DISABLE_PYTANGO_NUMPY
+/* Allow for downcast */
+
+inline unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong_2(PyObject *pylong)
+{
+ unsigned PY_LONG_LONG result = PyLong_AsUnsignedLongLong(pylong);
+ if(PyErr_Occurred())
+ {
+ PyErr_Clear();
+ result = PyLong_AsUnsignedLong(pylong);
+ }
+ return result;
+}
DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_BOOLEAN, long, PyLong_AsLong)
DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_UCHAR, unsigned long, PyLong_AsUnsignedLong)
@@ -165,7 +177,7 @@ DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_ULONG, unsigned long, PyLong_AsUnsignedL
DEFINE_FAST_TANGO_FROMPY(Tango::DEV_STATE, PyLong_AsLong)
DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_LONG64, Tango::DevLong64, PyLong_AsLongLong)
-DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_ULONG64, Tango::DevULong64, PyLong_AsUnsignedLongLong)
+DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_ULONG64, Tango::DevULong64, PyLong_AsUnsignedLongLong_2)
DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_FLOAT, double, PyFloat_AsDouble)
DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_DOUBLE, double, PyFloat_AsDouble)
@@ -228,7 +240,7 @@ struct array_element_from_py<Tango::DEVVAR_CHARARRAY>
PyErr_SetString(PyExc_TypeError, "Expecting a numeric type,"
" but it is not. If you use a numpy type instead of"
" python core types, then it must exactly match (ex:"
- " numpy.int32 for PyTango.DevLong (2))");
+ " numpy.int32 for PyTango.DevLong)");
boost::python::throw_error_already_set();
}
}
diff --git a/src/boost/cpp/server/attribute.cpp b/src/boost/cpp/server/attribute.cpp
index 6fb24d9..0e88137 100644
--- a/src/boost/cpp/server/attribute.cpp
+++ b/src/boost/cpp/server/attribute.cpp
@@ -82,7 +82,7 @@ namespace PyAttribute
*/
unique_pointer<TangoScalarType> cpp_val(new TangoScalarType);
- from_py<tangoTypeConst>::convert(value, *cpp_val);
+ from_py<tangoTypeConst>::convert(value.ptr(), *cpp_val);
att.set_value(cpp_val.release(), 1, 0, true);
}
diff --git a/src/boost/cpp/server/wattribute.cpp b/src/boost/cpp/server/wattribute.cpp
index eb4757d..5d63198 100644
--- a/src/boost/cpp/server/wattribute.cpp
+++ b/src/boost/cpp/server/wattribute.cpp
@@ -231,13 +231,16 @@ namespace PyWAttribute
boost::python::object &value)
{
typedef typename TANGO_const2type(tangoTypeConst) TangoScalarType;
- extract<TangoScalarType> val(value.ptr());
+ /*extract<TangoScalarType> val(value.ptr());
if (!val.check())
{
throw_wrong_python_data_type(att.get_name(), "set_write_value()");
}
- TangoScalarType cpp_val = val;
- att.set_write_value(cpp_val);
+ TangoScalarType cpp_value = val;
+ */
+ TangoScalarType cpp_value;
+ from_py<tangoTypeConst>::convert(value.ptr(), cpp_value);
+ att.set_write_value(cpp_value);
}
template<>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git
More information about the debian-science-commits
mailing list