diff --git a/c_bindings/pocketpy_c.cpp b/c_bindings/pocketpy_c.cpp index 07d3ab93..5fbe2ac3 100644 --- a/c_bindings/pocketpy_c.cpp +++ b/c_bindings/pocketpy_c.cpp @@ -171,7 +171,12 @@ static void propagate_if_errored(CVM* vm, ValueStackImpl* store } PyObject* c_function_wrapper(VM* vm, ArgsView args) { - LuaStyleFuncC f = py_cast(vm, args[-2])._lua_f; + LuaStyleFuncC f; + if(args[-1] != PY_NULL){ + f = _py_cast(vm, args[-1])._lua_f; + } else { + f = _py_cast(vm, args[-2])._lua_f; + } CVM* cvm = (CVM*) vm; //setup c stack