Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/pyTypeFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ static PyObject *callJSFunc(PyObject *jsCxThisFuncTuple, PyObject *args) {

JS::RootedVector<JS::Value> jsArgsVector(cx);
for (size_t i = 0; i < PyTuple_Size(args); i++) {
JS::Value jsValue = jsTypeFactory(cx, PyTuple_GetItem(args, i));
PyObject *pyObj = PyTuple_GetItem(args, i);
Py_INCREF(pyObj);
JS::Value jsValue = jsTypeFactory(cx, pyObj);
if (PyErr_Occurred()) { // Check if an exception has already been set in the flow of control
return NULL; // Fail-fast
}
Expand Down
11 changes: 11 additions & 0 deletions tests/python/test_pythonmonkey_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,17 @@ def add(a, b):
int2 = random.randint(0x0000, 0xFFFF)
assert caller(add, int1, int2) == int1 + int2

def test_eval_functions_pyfunction_in_closure():
# BF-58 https://github.com/Distributive-Network/PythonMonkey/pull/19
def fn1():
def fn0(n):
return n + 100
return fn0
assert 101.9 == fn1()(1.9)
assert 101.9 == pm.eval("(fn1) => { return fn1 }")(fn1())(1.9)
assert 101.9 == pm.eval("(fn1, x) => { return fn1()(x) }")(fn1, 1.9)
assert 101.9 == pm.eval("(fn1) => { return fn1() }")(fn1)(1.9)

def test_eval_functions_pyfunctions_strs():
caller = pm.eval("(func, param1, param2) => { return func(param1, param2) }")
def concatenate(a, b):
Expand Down