From 05348835d5504700e44b51b832e56cf1f30fd396 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 4 Apr 2011 08:46:12 +0000 Subject: Enable python component implementations to flow binary content strings. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1088509 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/python/eval.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sca-cpp/trunk/modules/python') diff --git a/sca-cpp/trunk/modules/python/eval.hpp b/sca-cpp/trunk/modules/python/eval.hpp index 65cd7f0ef7..c085aa42c3 100644 --- a/sca-cpp/trunk/modules/python/eval.hpp +++ b/sca-cpp/trunk/modules/python/eval.hpp @@ -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); -- cgit v1.2.3