Esempio n. 1
0
static int
PyTasklet_Setup_M(PyTaskletObject *task, PyObject *args, PyObject *kwds)
{
    PyObject *ret = PyStackless_Call_Main((PyObject*)task, args, kwds);

    return slp_return_wrapper(ret);
}
Esempio n. 2
0
PyObject *
PyStackless_CallMethod_Main(PyObject *o, char *name, char *format, ...)
{
	va_list va;
	PyObject *args, *func = NULL, *retval;

	if (o == NULL || name == NULL)
		return slp_null_error();

	func = PyObject_GetAttrString(o, name);
	if (func == NULL) {
		PyErr_SetString(PyExc_AttributeError, name);
		return NULL;
	}

	if (!PyCallable_Check(func))
		return slp_type_error("call of non-callable attribute");

	if (format && *format) {
		va_start(va, format);
		args = Py_VaBuildValue(format, va);
		va_end(va);
	}
	else
		args = PyTuple_New(0);

	if (!args)
		return NULL;

	if (!PyTuple_Check(args)) {
		PyObject *a;

		a = PyTuple_New(1);
		if (a == NULL)
			return NULL;
		if (PyTuple_SetItem(a, 0, args) < 0)
			return NULL;
		args = a;
	}

	/* retval = PyObject_CallObject(func, args); */
	retval = PyStackless_Call_Main(func, args, NULL);

	Py_DECREF(args);
	Py_DECREF(func);

	return retval;
}