Skip to content

Commit

Permalink
convert to String Obj, then to Unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbank committed Apr 13, 2016
1 parent 5d9a344 commit 318107e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/py_object_wrapper.cc
Expand Up @@ -556,13 +556,15 @@ Handle<Value> PyObjectWrapper::InstanceToString(const FunctionCallbackInfo<Value

PyObject* py_object = InstanceGetPyObject();

PyObject* py_unicode = PyUnicode_FromObject(py_object);
PyObject* py_string = PyObject_Str(py_object);
PyObject* py_unicode = PyUnicode_FromObject(py_string);
if (py_unicode == NULL)
return ThrowPythonException();

Local<String> js_string = String::NewFromTwoByte(Isolate::GetCurrent(), PyUnicode_AsUnicode(py_unicode));

Py_XDECREF(py_unicode);
Py_XDECREF(py_string);

return scope.Escape(js_string);
}
Expand Down

0 comments on commit 318107e

Please sign in to comment.