summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/python
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-04-04 08:46:12 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-04-04 08:46:12 +0000
commit05348835d5504700e44b51b832e56cf1f30fd396 (patch)
tree23775ff27c1cbd22989023cc167cf806fea5fb5e /sca-cpp/trunk/modules/python
parent038525403ebcc1d69436adad9bc1cfabb371dae1 (diff)
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
Diffstat (limited to 'sca-cpp/trunk/modules/python')
-rw-r--r--sca-cpp/trunk/modules/python/eval.hpp14
1 files changed, 9 insertions, 5 deletions
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);