mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.
This commit is contained in:
parent
4157ffbb96
commit
f841aa6fc0
2 changed files with 58 additions and 0 deletions
|
@ -43,11 +43,39 @@ spamlist_setstate(spamlistobject *self, PyObject *args)
|
|||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
spamlist_specialmeth(PyObject *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
PyObject *result = PyTuple_New(3);
|
||||
|
||||
if (result != NULL) {
|
||||
if (self == NULL)
|
||||
self = Py_None;
|
||||
if (kw == NULL)
|
||||
kw = Py_None;
|
||||
Py_INCREF(self);
|
||||
PyTuple_SET_ITEM(result, 0, self);
|
||||
Py_INCREF(args);
|
||||
PyTuple_SET_ITEM(result, 1, args);
|
||||
Py_INCREF(kw);
|
||||
PyTuple_SET_ITEM(result, 2, kw);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static PyMethodDef spamlist_methods[] = {
|
||||
{"getstate", (PyCFunction)spamlist_getstate, METH_VARARGS,
|
||||
"getstate() -> state"},
|
||||
{"setstate", (PyCFunction)spamlist_setstate, METH_VARARGS,
|
||||
"setstate(state)"},
|
||||
/* These entries differ only in the flags; they are used by the tests
|
||||
in test.test_descr. */
|
||||
{"classmeth", (PyCFunction)spamlist_specialmeth,
|
||||
METH_VARARGS | METH_KEYWORDS | METH_CLASS,
|
||||
"classmeth(*args, **kw)"},
|
||||
{"staticmeth", (PyCFunction)spamlist_specialmeth,
|
||||
METH_VARARGS | METH_KEYWORDS | METH_STATIC,
|
||||
"staticmeth(*args, **kw)"},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue