From 57baae294f2f91ad478360ee3bf96e9b72ffe1c3 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 25 Apr 2018 11:45:50 -0400 Subject: [PATCH] Support converting ArrayBuffer to Python bytes --- src/js2python.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); + } } }