101 static int py_object_call(lua_State *L)
102 {
103 py_object *obj = (py_object*) luaL_checkudata(L, 1, POBJECT);
104 PyObject *args;
105 PyObject *value;
106 int nargs = lua_gettop(L)-1;
107 int ret = 0;
108 int i;
109
110 if (!obj) {
111 luaL_argerror(L, 1, "not a python object");
when treating unknown void * from src/pythoninlua.c:104 as non-NULL
taking False path
112 return 0;
113 }
114 if (!PyCallable_Check(obj->o)) {
115 luaL_error(L, "object is not callable");
when PyCallable_Check() returns 1 (true)
taking False path
116 return 0;
117 }
118
119 args = PyTuple_New(nargs);
120 if (!args) {
when PyTuple_New() succeeds
PyTupleObject allocated at: args = PyTuple_New(nargs);
ob_refcnt is now refs: 1 + N where N >= 0
121 PyErr_Print();
taking False path
122 luaL_error(L, "failed to create arguments tuple");
123 return 0;
124 }
125
126 for (i = 0; i != nargs; i++) {
127 PyObject *arg = LuaConvert(L, i+2);
when considering value == (int)0 from src/pythoninlua.c:107
taking False path
128 if (!arg) {
129 luaL_error(L, "failed to convert argument #%d", i+1);
130 Py_DECREF(args);
131 return 0;
132 }
133 PyTuple_SetItem(args, i, arg);
134 }
135
136 value = PyObject_CallObject(obj->o, args);
137 if (value) {
when treating unknown struct PyObject * from src/pythoninlua.c:137 as non-NULL
when PyObject_CallObject() succeeds
138 ret = py_convert(L, value, 0);
taking True path
139 Py_DECREF(value);
140 } else {
when taking True path
141 PyErr_Print();
142 luaL_error(L, "error calling python function");
143 }
144
145 return ret;
146 }
147