- PyObject *arglist;
- PyObject *result;
-
- assert(action >= 0 && action < OBActions::NUM_ACTIONS);
-
- if (d4 != LONG_MIN)
- arglist = Py_BuildValue("iliillll", action, window, type, state,
- d1, d2, d3, d4);
- else if (d3 != LONG_MIN)
- arglist = Py_BuildValue("iliilll", action, window, type, state,
- d1, d2, d3);
- else if (d2 != LONG_MIN)
- arglist = Py_BuildValue("iliill", action, window, type, state, d1, d2);
- else if (d1 != LONG_MIN)
- arglist = Py_BuildValue("iliil", action, window, type, state, d1);
- else
- arglist = Py_BuildValue("ilii", action, window, type, state);
-
- FunctionList::iterator it, end = callbacks[action].end();
- for (it = callbacks[action].begin(); it != end; ++it) {
- // call the callback
- result = PyEval_CallObject(*it, arglist);
- if (result) {
- Py_DECREF(result);
- } else {
- // an exception occured in the script, display it
- PyErr_Print();
+ if (!PyList_Check(keylist)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
+ return NULL;
+ }
+ if (!PyCallable_Check(func)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
+ return NULL;
+ }
+
+ ob::Bindings::StringVect vectkeylist;
+ for (int i = 0, end = PyList_Size(keylist); i < end; ++i) {
+ PyObject *str = PyList_GetItem(keylist, i);
+ if (!PyString_Check(str)) {
+ PyErr_SetString(PyExc_TypeError,
+ "Invalid keylist. It must contain only strings.");
+ return NULL;