Skip to content

Commit 9c66097

Browse files
committed
fix(pm.eval): don't destroy the root for returning bound functions
1 parent e0b0a09 commit 9c66097

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/modules/pythonmonkey/pythonmonkey.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ static PyObject *eval(PyObject *self, PyObject *args) {
253253
js::ESClass cls = js::ESClass::Other; // placeholder if `rval` is not a JSObject
254254
if (rval->isObject()) {
255255
JS::GetBuiltinClass(GLOBAL_CX, JS::RootedObject(GLOBAL_CX, &rval->toObject()), &cls);
256+
if (JS_ObjectIsBoundFunction(&rval->toObject())) {
257+
cls = js::ESClass::Function; // In SpiderMonkey 115 ESR, bound function is no longer a JSFunction but a js::BoundFunctionObject.
258+
}
256259
}
257260
bool rvalIsFunction = cls == js::ESClass::Function; // function object
258261
bool rvalIsString = rval->isString() || cls == js::ESClass::String; // string primitive or boxed String object

0 commit comments

Comments
 (0)