Support converting ArrayBuffer to Python bytes

This commit is contained in:
Michael Droettboom 2018-04-25 11:45:50 -04:00
parent 5f42b61862
commit 57baae294f
1 changed files with 6 additions and 1 deletions

View File

@ -33,9 +33,14 @@ PyObject *jsToPython(val x) {
Py_INCREF(pypy_x); Py_INCREF(pypy_x);
return pypy_x; return pypy_x;
} else { } else {
try {
std::string x_str = x.as<std::string>();
return PyBytes_FromStringAndSize(x_str.c_str(), x_str.size());
} catch (...) {
return JsProxy_cnew(x); return JsProxy_cnew(x);
} }
} }
}
PyObject *jsToPythonArgs(val args) { PyObject *jsToPythonArgs(val args) {
if (!Array->call<bool>("isArray", args)) { if (!Array->call<bool>("isArray", args)) {