tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1088509 - /tuscany/sca-cpp/trunk/modules/python/eval.hpp
Date Mon, 04 Apr 2011 08:46:12 GMT
Author: jsdelfino
Date: Mon Apr  4 08:46:12 2011
New Revision: 1088509

URL: http://svn.apache.org/viewvc?rev=1088509&view=rev
Log:
Enable python component implementations to flow binary content strings.

Modified:
    tuscany/sca-cpp/trunk/modules/python/eval.hpp

Modified: tuscany/sca-cpp/trunk/modules/python/eval.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/python/eval.hpp?rev=1088509&r1=1088508&r2=1088509&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/python/eval.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/python/eval.hpp Mon Apr  4 08:46:12 2011
@@ -207,8 +207,10 @@ PyObject* valueToPyObject(const value& v
         return mkPyLambda(v);
     case value::Symbol:
         return PyString_FromString(c_str(string("'") + v));
-    case value::String:
-        return PyString_FromString(c_str(v));
+    case value::String: {
+        const string s = (string)v;
+        return PyString_FromStringAndSize(c_str(s), length(s));
+    }
     case value::Number:
         return PyFloat_FromDouble((double)v);
     case value::Bool:
@@ -261,10 +263,12 @@ struct pyCallable {
  */
 const value pyObjectToValue(PyObject *o) {
     if (PyString_Check(o)) {
-        const char* s = PyString_AsString(o);
-        if (*s == '\'')
+        char* s = NULL;
+        Py_ssize_t l = 0;
+        PyString_AsStringAndSize(o, &s, &l);
+        if (l != 0 && *s == '\'')
             return value(s + 1);
-        return value(string(s));
+        return value(string(s, l));
     }
     if (PyBool_Check(o))
         return value(o == Py_True);



Mime
View raw message