diff --git a/src/js2python.cpp b/src/js2python.cpp index abe00a1ad..3fcff5ead 100644 --- a/src/js2python.cpp +++ b/src/js2python.cpp @@ -33,7 +33,12 @@ PyObject *jsToPython(val x) { Py_INCREF(pypy_x); return pypy_x; } else { - return JsProxy_cnew(x); + try { + std::string x_str = x.as(); + return PyBytes_FromStringAndSize(x_str.c_str(), x_str.size()); + } catch (...) { + return JsProxy_cnew(x); + } } }