[pytango] 141/483: preparing for version 8

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:34 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 8bb15b4aafa8b94d3d0fa88f341e862f98a61d43
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Fri Sep 21 12:54:39 2012 +0000

    preparing for version 8
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@21157 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 doc/man/itango.1   |  47 ++++--------------
 doc/quicktour.rst  |  48 +++++++++---------
 src/fast_from_py.h |  31 ------------
 src/from_py.cpp    | 143 +++++++++++++++++++++++++++++++++++------------------
 src/from_py.h      |  14 ++++++
 src/pyutils.cpp    |  14 ++++++
 src/pyutils.h      |   9 ++++
 src/to_py.cpp      |   2 +-
 src/to_py.h        |   6 ++-
 9 files changed, 171 insertions(+), 143 deletions(-)

diff --git a/doc/man/itango.1 b/doc/man/itango.1
index 89bc375..da57541 100644
--- a/doc/man/itango.1
+++ b/doc/man/itango.1
@@ -1,50 +1,21 @@
-.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.38.4.
-.TH SARDANA "1" "January 2012" "Sardana 1.0.0" "User Commands"
+.TH ITANGO "1" "September 2012" "ITango 8.0.0" "User Commands"
 .SH NAME
-Sardana \- manual page for Sardana 1.0.0
+PyTango \- manual page for ITango 8.0.0
 .SH SYNOPSIS
 .B usage:
-\fISardana instance_name \fR[\fIoptions\fR]
-.SH OPTIONS
-.TP
-\fB\-\-version\fR
-show program's version number and exit
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-show this help message and exit
-.TP
-\fB\-\-log\-level\fR=\fILOG_LEVEL\fR
-log output level. Possible values are (case
-sensitive): critical (or 0), error (1), warning (2),
-info (3) debug (4), trace (5) [default: warning]
-.TP
-\fB\-\-log\-file\-level\fR=\fILOG_FILE_LEVEL\fR
-log file level. Possible values are (case sensitive):
-critical (or 0), error (1), warning (2), info (3)
-debug (4), trace (5) [default: debug]. Ignored if
-\fB\-\-without\-log\-file\fR is True
-.TP
-\fB\-\-log\-file\-name\fR=\fILOG_FILE_NAME\fR
-log file name. When given, MUST be absolute file name.
-[default: /tmp/tango/<DS name>/<DS instance name lower
-case>/log.txt]. Ignored if \fB\-\-without\-log\-file\fR is True
-.TP
-\fB\-\-without\-log\-file\fR=\fIWITHOUT_LOG_FILE\fR
-When set to True disables logging into a file
-[default: False]
-.TP
-\fB\-\-rconsole\-port\fR=\fIRCONSOLE_PORT\fR
-rconsole port number. [default: 0 meaning rconsole NOT
-active]
+\fIitango \fR[\fIIPython options\fR]
 .SH "SEE ALSO"
+The documentation for
+.B IPython
+
 The full documentation for
-.B Sardana
+.B ITango
 is maintained as a Texinfo manual.  If the
 .B info
 and
-.B Sardana
+.B ITango
 programs are properly installed at your site, the command
 .IP
-.B info Sardana
+.B info itango
 .PP
 should give you access to the complete manual.
diff --git a/doc/quicktour.rst b/doc/quicktour.rst
index 8766bb6..ec51701 100644
--- a/doc/quicktour.rst
+++ b/doc/quicktour.rst
@@ -323,28 +323,28 @@ API should be accessed from Python.
 
         ITango [3]: # Getting Device Properties
         ITango [4]: property_names = ["AxisBoxAttachement",
-                           ....:                   "AxisEncoderType",
-                           ....:                   "AxisNumber",
-                           ....:                   "CurrentAcceleration",
-                           ....:                   "CurrentAccuracy",
-                           ....:                   "CurrentBacklash",
-                           ....:                   "CurrentDeceleration",
-                           ....:                   "CurrentDirection",
-                           ....:                   "CurrentMotionAccuracy",
-                           ....:                   "CurrentOvershoot",
-                           ....:                   "CurrentRetry",
-                           ....:                   "CurrentScale",
-                           ....:                   "CurrentSpeed",
-                           ....:                   "CurrentVelocity",
-                           ....:                   "EncoderMotorRatio",
-                           ....:                   "logging_level",
-                           ....:                   "logging_target",
-                           ....:                   "UserEncoderRatio",
-                           ....:                   "UserOffset"]
-        
+              ....:                   "AxisEncoderType",
+              ....:                   "AxisNumber",
+              ....:                   "CurrentAcceleration",
+              ....:                   "CurrentAccuracy",
+              ....:                   "CurrentBacklash",
+              ....:                   "CurrentDeceleration",
+              ....:                   "CurrentDirection",
+              ....:                   "CurrentMotionAccuracy",
+              ....:                   "CurrentOvershoot",
+              ....:                   "CurrentRetry",
+              ....:                   "CurrentScale",
+              ....:                   "CurrentSpeed",
+              ....:                   "CurrentVelocity",
+              ....:                   "EncoderMotorRatio",
+              ....:                   "logging_level",
+              ....:                   "logging_target",
+              ....:                   "UserEncoderRatio",
+              ....:                   "UserOffset"]
+       
         ITango [5]: axis_properties = axis1.get_property(property_names)
         ITango [6]: for prop in axis_properties.keys():
-                           ....:     print "%s: %s" % (prop, axis_properties[prop][0])
+              ....:     print "%s: %s" % (prop, axis_properties[prop][0])
 
         ITango [7]: # Changing Properties
         ITango [8]: axis_properties["AxisBoxAttachement"] = ["microxas/motorisation/galilbox"]
@@ -355,8 +355,8 @@ API should be accessed from Python.
         ITango [12]: # Reading attributes
         ITango [13]: att_list = axis.get_attribute_list()
         ITango [14]: for att in att_list:
-                            ....:     att_val = axis.read_attribute(att)
-                            ....:     print "%s: %s" % (att.name, att_val.value)
+               ....:     att_val = axis.read_attribute(att)
+               ....:     print "%s: %s" % (att.name, att_val.value)
 
         ITango [15]: # Changing some attribute values
         ITango [16]: axis1.write_attribute("AxisBackslash", 0.5)
@@ -368,8 +368,8 @@ API should be accessed from Python.
         ITango [21]: pos1=axis1.read_attribute("AxisCurrentPosition")
         ITango [22]: axis1.command_inout("AxisBackward")
         ITango [23]: while pos1.value > 1000.0:
-                            ....:     pos1 = axis1.read_attribute("AxisCurrentPosition")
-                            ....:     print "position axis 1 = ", pos1.value
+               ....:     pos1 = axis1.read_attribute("AxisCurrentPosition")
+               ....:     print "position axis 1 = ", pos1.value
                             
         ITango [24]: axis1.command_inout("AxisStop")
 
diff --git a/src/fast_from_py.h b/src/fast_from_py.h
index 3ca7d33..61ac155 100644
--- a/src/fast_from_py.h
+++ b/src/fast_from_py.h
@@ -176,37 +176,6 @@ DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_ULONG64, Tango::DevULong64, PyLong_AsUns
 DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_FLOAT, double, PyFloat_AsDouble)
 DEFINE_FAST_TANGO_FROMPY_NUM(Tango::DEV_DOUBLE, double, PyFloat_AsDouble)
 
-inline char* obj_to_new_char(PyObject* obj_ptr)
-{
-    Tango::DevString ret = NULL;
-    if(PyUnicode_Check(obj_ptr))
-    {
-        PyObject* obj_bytes_ptr = PyUnicode_AsLatin1String(obj_ptr);
-        ret = CORBA::string_dup(PyBytes_AsString(obj_bytes_ptr));
-        Py_DECREF(obj_bytes_ptr);
-    }
-    else
-    {
-        ret = CORBA::string_dup(PyBytes_AsString(obj_ptr));
-    }
-    return ret;
-}
-
-inline char* obj_to_new_char(boost::python::object &obj)
-{
-    return obj_to_new_char(obj.ptr());
-}
-
-
-/// @bug Not a bug per se, but you should keep in mind: It returns a new
-/// string, so if you pass it to Tango with a release flag there will be
-/// no problems, but if you have to use it yourself then you must remember
-/// to delete[] it!
-inline Tango::DevString PyString_AsCorbaString(PyObject* obj_ptr)
-{
-    return obj_to_new_char(obj_ptr);
-}
-
 // DEFINE_FAST_TANGO_FROMPY(Tango::DEV_STRING, PyString_AsString)
 DEFINE_FAST_TANGO_FROMPY(Tango::DEV_STRING, PyString_AsCorbaString)
 
diff --git a/src/from_py.cpp b/src/from_py.cpp
index e18f6bf..b13bcc7 100644
--- a/src/from_py.cpp
+++ b/src/from_py.cpp
@@ -26,6 +26,55 @@
 
 using namespace boost::python;
 
+char* obj_to_new_char(PyObject* obj_ptr)
+{
+    Tango::DevString ret = NULL;
+    if(PyUnicode_Check(obj_ptr))
+    {
+        PyObject* obj_bytes_ptr = PyUnicode_AsLatin1String(obj_ptr);
+        ret = CORBA::string_dup(PyBytes_AsString(obj_bytes_ptr));
+        Py_DECREF(obj_bytes_ptr);
+    }
+    else
+    {
+        ret = CORBA::string_dup(PyBytes_AsString(obj_ptr));
+    }
+    return ret;
+}
+
+char* obj_to_new_char(bopy::object obj)
+{
+    return obj_to_new_char(obj.ptr());
+}
+
+void obj_to_string(PyObject* obj_ptr, std::string& result)
+{
+    if(PyUnicode_Check(obj_ptr))
+    {
+        PyObject* obj_bytes_ptr = PyUnicode_AsLatin1String(obj_ptr);
+        result = PyBytes_AsString(obj_bytes_ptr);
+        Py_DECREF(obj_bytes_ptr);
+    }
+    else
+    {
+        result = PyBytes_AsString(obj_ptr);
+    }
+}
+
+void obj_to_string(bopy::object obj, std::string& result)
+{
+    return obj_to_string(obj.ptr(), result);
+}
+
+/// @bug Not a bug per se, but you should keep in mind: It returns a new
+/// string, so if you pass it to Tango with a release flag there will be
+/// no problems, but if you have to use it yourself then you must remember
+/// to delete[] it!
+Tango::DevString PyString_AsCorbaString(PyObject* obj_ptr)
+{
+    return obj_to_new_char(obj_ptr);
+}
+
 void convert2array(const boost::python::object &py_value, Tango::DevVarCharArray & result)
 {
     PyObject *py_value_ptr = py_value.ptr();
@@ -153,35 +202,35 @@ void convert2array(const boost::python::object &py_value, Tango::DevVarLongStrin
     convert2array(py_str, result.svalue);
 }
 
-void from_py_object(object &py_obj, Tango::AttributeAlarm &attr_alarm)
+void from_py_object(bopy::object &py_obj, Tango::AttributeAlarm &attr_alarm)
 {
-    attr_alarm.min_alarm = extract<const char *>(py_obj.attr("min_alarm"));
-    attr_alarm.max_alarm = extract<const char *>(py_obj.attr("max_alarm"));
-    attr_alarm.min_warning = extract<const char *>(py_obj.attr("min_warning"));
-    attr_alarm.max_warning = extract<const char *>(py_obj.attr("max_warning"));
-    attr_alarm.delta_t = extract<const char *>(py_obj.attr("delta_t"));
-    attr_alarm.delta_val = extract<const char *>(py_obj.attr("delta_val"));
+    attr_alarm.min_alarm = obj_to_new_char(py_obj.attr("min_alarm"));
+    attr_alarm.max_alarm = obj_to_new_char(py_obj.attr("max_alarm"));
+    attr_alarm.min_warning = obj_to_new_char(py_obj.attr("min_warning"));
+    attr_alarm.max_warning = obj_to_new_char(py_obj.attr("max_warning"));
+    attr_alarm.delta_t = obj_to_new_char(py_obj.attr("delta_t"));
+    attr_alarm.delta_val = obj_to_new_char(py_obj.attr("delta_val"));
     convert2array(py_obj.attr("extensions"), attr_alarm.extensions);
 }
 
 void from_py_object(object &py_obj, Tango::ChangeEventProp &change_evt_prop)
 {
-    change_evt_prop.rel_change = extract<const char *>(py_obj.attr("rel_change"));
-    change_evt_prop.abs_change = extract<const char *>(py_obj.attr("abs_change"));
+    change_evt_prop.rel_change = obj_to_new_char(py_obj.attr("rel_change"));
+    change_evt_prop.abs_change = obj_to_new_char(py_obj.attr("abs_change"));
     convert2array(py_obj.attr("extensions"), change_evt_prop.extensions);
 }
 
 void from_py_object(object &py_obj, Tango::PeriodicEventProp &periodic_evt_prop)
 {
-    periodic_evt_prop.period = extract<const char *>(py_obj.attr("period"));
+    periodic_evt_prop.period = obj_to_new_char(py_obj.attr("period"));
     convert2array(py_obj.attr("extensions"), periodic_evt_prop.extensions);
 }
 
 void from_py_object(object &py_obj, Tango::ArchiveEventProp &archive_evt_prop)
 {
-    archive_evt_prop.rel_change = extract<const char *>(py_obj.attr("rel_change"));
-    archive_evt_prop.abs_change = extract<const char *>(py_obj.attr("abs_change"));
-    archive_evt_prop.period = extract<const char *>(py_obj.attr("period"));
+    archive_evt_prop.rel_change = obj_to_new_char(py_obj.attr("rel_change"));
+    archive_evt_prop.abs_change = obj_to_new_char(py_obj.attr("abs_change"));
+    archive_evt_prop.period = obj_to_new_char(py_obj.attr("period"));
     convert2array(py_obj.attr("extensions"), archive_evt_prop.extensions);
 }
 
@@ -199,66 +248,66 @@ void from_py_object(object &py_obj, Tango::EventProperties &evt_props)
 
 void from_py_object(object &py_obj, Tango::AttributeConfig &attr_conf)
 {
-    attr_conf.name = extract<const char *>(py_obj.attr("name"));
+    attr_conf.name = obj_to_new_char(py_obj.attr("name"));
     attr_conf.writable = extract<Tango::AttrWriteType>(py_obj.attr("writable"));
     attr_conf.data_format = extract<Tango::AttrDataFormat>(py_obj.attr("data_format"));
     attr_conf.data_type = extract<CORBA::Long>(py_obj.attr("data_type"));
     attr_conf.max_dim_x = extract<CORBA::Long>(py_obj.attr("max_dim_x"));
     attr_conf.max_dim_y = extract<CORBA::Long>(py_obj.attr("max_dim_y"));
-    attr_conf.description = extract<const char *>(py_obj.attr("description"));
-    attr_conf.label = extract<const char *>(py_obj.attr("label"));
-    attr_conf.unit = extract<const char *>(py_obj.attr("unit"));
-    attr_conf.standard_unit = extract<const char *>(py_obj.attr("standard_unit"));
-    attr_conf.display_unit = extract<const char *>(py_obj.attr("display_unit"));
-    attr_conf.format = extract<const char *>(py_obj.attr("format"));
-    attr_conf.min_value = extract<const char *>(py_obj.attr("min_value"));
-    attr_conf.max_value = extract<const char *>(py_obj.attr("max_value"));
-    attr_conf.min_alarm = extract<const char *>(py_obj.attr("min_alarm"));
-    attr_conf.max_alarm = extract<const char *>(py_obj.attr("max_alarm"));
-    attr_conf.writable_attr_name = extract<const char *>(py_obj.attr("writable_attr_name"));
+    attr_conf.description = obj_to_new_char(py_obj.attr("description"));
+    attr_conf.label = obj_to_new_char(py_obj.attr("label"));
+    attr_conf.unit = obj_to_new_char(py_obj.attr("unit"));
+    attr_conf.standard_unit = obj_to_new_char(py_obj.attr("standard_unit"));
+    attr_conf.display_unit = obj_to_new_char(py_obj.attr("display_unit"));
+    attr_conf.format = obj_to_new_char(py_obj.attr("format"));
+    attr_conf.min_value = obj_to_new_char(py_obj.attr("min_value"));
+    attr_conf.max_value = obj_to_new_char(py_obj.attr("max_value"));
+    attr_conf.min_alarm = obj_to_new_char(py_obj.attr("min_alarm"));
+    attr_conf.max_alarm = obj_to_new_char(py_obj.attr("max_alarm"));
+    attr_conf.writable_attr_name = obj_to_new_char(py_obj.attr("writable_attr_name"));
     convert2array(py_obj.attr("extensions"), attr_conf.extensions);
 }
 
 void from_py_object(object &py_obj, Tango::AttributeConfig_2 &attr_conf)
 {
-    attr_conf.name = extract<const char *>(py_obj.attr("name"));
+    attr_conf.name = obj_to_new_char(py_obj.attr("name"));
     attr_conf.writable = extract<Tango::AttrWriteType>(py_obj.attr("writable"));
     attr_conf.data_format = extract<Tango::AttrDataFormat>(py_obj.attr("data_format"));
     attr_conf.data_type = extract<CORBA::Long>(py_obj.attr("data_type"));
     attr_conf.max_dim_x = extract<CORBA::Long>(py_obj.attr("max_dim_x"));
     attr_conf.max_dim_y = extract<CORBA::Long>(py_obj.attr("max_dim_y"));
-    attr_conf.description = extract<const char *>(py_obj.attr("description"));
-    attr_conf.label = extract<const char *>(py_obj.attr("label"));
-    attr_conf.unit = extract<const char *>(py_obj.attr("unit"));
-    attr_conf.standard_unit = extract<const char *>(py_obj.attr("standard_unit"));
-    attr_conf.display_unit = extract<const char *>(py_obj.attr("display_unit"));
-    attr_conf.format = extract<const char *>(py_obj.attr("format"));
-    attr_conf.min_value = extract<const char *>(py_obj.attr("min_value"));
-    attr_conf.max_value = extract<const char *>(py_obj.attr("max_value"));
-    attr_conf.min_alarm = extract<const char *>(py_obj.attr("min_alarm"));
-    attr_conf.max_alarm = extract<const char *>(py_obj.attr("max_alarm"));
-    attr_conf.writable_attr_name = extract<const char *>(py_obj.attr("writable_attr_name"));
+    attr_conf.description = obj_to_new_char(py_obj.attr("description"));
+    attr_conf.label = obj_to_new_char(py_obj.attr("label"));
+    attr_conf.unit = obj_to_new_char(py_obj.attr("unit"));
+    attr_conf.standard_unit = obj_to_new_char(py_obj.attr("standard_unit"));
+    attr_conf.display_unit = obj_to_new_char(py_obj.attr("display_unit"));
+    attr_conf.format = obj_to_new_char(py_obj.attr("format"));
+    attr_conf.min_value = obj_to_new_char(py_obj.attr("min_value"));
+    attr_conf.max_value = obj_to_new_char(py_obj.attr("max_value"));
+    attr_conf.min_alarm = obj_to_new_char(py_obj.attr("min_alarm"));
+    attr_conf.max_alarm = obj_to_new_char(py_obj.attr("max_alarm"));
+    attr_conf.writable_attr_name = obj_to_new_char(py_obj.attr("writable_attr_name"));
     attr_conf.level = extract<Tango::DispLevel>(py_obj.attr("level"));
     convert2array(py_obj.attr("extensions"), attr_conf.extensions);
 }
 
 void from_py_object(object &py_obj, Tango::AttributeConfig_3 &attr_conf)
 {
-    attr_conf.name = extract<const char *>(py_obj.attr("name"));
+    attr_conf.name = obj_to_new_char(py_obj.attr("name"));
     attr_conf.writable = extract<Tango::AttrWriteType>(py_obj.attr("writable"));
     attr_conf.data_format = extract<Tango::AttrDataFormat>(py_obj.attr("data_format"));
     attr_conf.data_type = extract<CORBA::Long>(py_obj.attr("data_type"));
     attr_conf.max_dim_x = extract<CORBA::Long>(py_obj.attr("max_dim_x"));
     attr_conf.max_dim_y = extract<CORBA::Long>(py_obj.attr("max_dim_y"));
-    attr_conf.description = extract<const char *>(py_obj.attr("description"));
-    attr_conf.label = extract<const char *>(py_obj.attr("label"));
-    attr_conf.unit = extract<const char *>(py_obj.attr("unit"));
-    attr_conf.standard_unit = extract<const char *>(py_obj.attr("standard_unit"));
-    attr_conf.display_unit = extract<const char *>(py_obj.attr("display_unit"));
-    attr_conf.format = extract<const char *>(py_obj.attr("format"));
-    attr_conf.min_value = extract<const char *>(py_obj.attr("min_value"));
-    attr_conf.max_value = extract<const char *>(py_obj.attr("max_value"));
-    attr_conf.writable_attr_name = extract<const char *>(py_obj.attr("writable_attr_name"));
+    attr_conf.description = obj_to_new_char(py_obj.attr("description"));
+    attr_conf.label = obj_to_new_char(py_obj.attr("label"));
+    attr_conf.unit = obj_to_new_char(py_obj.attr("unit"));
+    attr_conf.standard_unit = obj_to_new_char(py_obj.attr("standard_unit"));
+    attr_conf.display_unit = obj_to_new_char(py_obj.attr("display_unit"));
+    attr_conf.format = obj_to_new_char(py_obj.attr("format"));
+    attr_conf.min_value = obj_to_new_char(py_obj.attr("min_value"));
+    attr_conf.max_value = obj_to_new_char(py_obj.attr("max_value"));
+    attr_conf.writable_attr_name = obj_to_new_char(py_obj.attr("writable_attr_name"));
     attr_conf.level = extract<Tango::DispLevel>(py_obj.attr("level"));
     
     object py_att_alarm = py_obj.attr("att_alarm");
diff --git a/src/from_py.h b/src/from_py.h
index 4437fa1..0ab46cf 100644
--- a/src/from_py.h
+++ b/src/from_py.h
@@ -38,6 +38,20 @@
 
 extern const char *param_must_be_seq;
 
+char* obj_to_new_char(PyObject* obj_ptr);
+
+char* obj_to_new_char(bopy::object obj);
+
+void obj_to_string(PyObject* obj_ptr, std::string& result);
+
+void obj_to_string(bopy::object obj, std::string& result);
+
+/// @bug Not a bug per se, but you should keep in mind: It returns a new
+/// string, so if you pass it to Tango with a release flag there will be
+/// no problems, but if you have to use it yourself then you must remember
+/// to delete[] it!
+Tango::DevString PyString_AsCorbaString(PyObject* obj_ptr);
+
 /**
  * Converter from python sequence of strings to a std::vector<std::string>
  *
diff --git a/src/pyutils.cpp b/src/pyutils.cpp
index 89e1879..fdfa556 100644
--- a/src/pyutils.cpp
+++ b/src/pyutils.cpp
@@ -27,6 +27,20 @@
 
 using namespace boost::python;
 
+bopy::object from_char_to_str2(const std::string& in, 
+                               const char* encoding /*=NULL defaults to latin-1 */,
+                               const char* errors /*="strict" */)
+{
+    return from_char_to_str2(in.c_str(), in.size(), encoding, errors);
+}
+
+bopy::object from_char_to_str2(const char* in, Py_ssize_t size /* =-1 */, 
+                               const char* encoding /*=NULL defaults to latin-1 */,
+                               const char* errors /*="strict" */)
+{
+    return bopy::object(bopy::handle<>(from_char_to_str(in, size, encoding, errors)));
+}
+
 PyObject* from_char_to_str(const std::string& in, 
                            const char* encoding /*=NULL defaults to latin-1 */,
                            const char* errors /*="strict" */)
diff --git a/src/pyutils.h b/src/pyutils.h
index 4f7acfc..686dddb 100644
--- a/src/pyutils.h
+++ b/src/pyutils.h
@@ -243,6 +243,15 @@ PyObject* from_char_to_str(const std::string& in,
                            const char* encoding=NULL, /* defaults to latin-1 */
                            const char* errors="strict");
 
+bopy::object from_char_to_str2(const char* in, Py_ssize_t size=-1, 
+                               const char* encoding=NULL, /* defaults to latin-1 */
+                               const char* errors="strict");
+
+bopy::object from_char_to_str2(const std::string& in,
+                               const char* encoding=NULL, /* defaults to latin-1 */
+                               const char* errors="strict");
+
+
 void from_str_to_char(PyObject* in, std::string& out);
 
 inline void raise_(PyObject *type, const char *message)
diff --git a/src/to_py.cpp b/src/to_py.cpp
index a7932f4..c093e52 100644
--- a/src/to_py.cpp
+++ b/src/to_py.cpp
@@ -222,4 +222,4 @@ boost::python::list to_py(const Tango::AttributeConfigList_3 &attr_conf_list)
         py_attr_conf_list.append(to_py(attr_conf, none));
     }
     return py_attr_conf_list;
-}
\ No newline at end of file
+}
diff --git a/src/to_py.h b/src/to_py.h
index d9716ae..d12f2f6 100644
--- a/src/to_py.h
+++ b/src/to_py.h
@@ -34,8 +34,10 @@ struct DevEncoded_to_tuple
     static inline PyObject* convert(Tango::DevEncoded const& a)
     {
         boost::python::str encoded_format(a.encoded_format);
-        boost::python::str encoded_data(
-            (const char*)a.encoded_data.get_buffer(), a.encoded_data.length());
+        bopy::object encoded_data = bopy::object(
+            bopy::handle<>(PyBytes_FromStringAndSize(
+                (const char*)a.encoded_data.get_buffer(),
+                (Py_ssize_t)a.encoded_data.length())));
         boost::python::object result = boost::python::make_tuple(encoded_format, encoded_data);
         return boost::python::incref(result.ptr());
     }

-- 
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