0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

updated for version 7.3.1060

Problem:    Python: can't repr() a function.
Solution:   Python patch 19: add FunctionRepr(). (ZyX)
This commit is contained in:
Bram Moolenaar
2013-05-30 12:43:54 +02:00
parent 1a3b56953e
commit a5b725c3f6
2 changed files with 9 additions and 0 deletions

View File

@@ -1584,6 +1584,12 @@ FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs)
return result;
}
static PyObject *
FunctionRepr(FunctionObject *self)
{
return PyString_FromFormat("<vim.Function '%s'>", self->name);
}
static struct PyMethodDef FunctionMethods[] = {
{"__call__",(PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""},
{"__dir__", (PyCFunction)FunctionDir, METH_NOARGS, ""},
@@ -4640,6 +4646,7 @@ init_structs(void)
FunctionType.tp_flags = Py_TPFLAGS_DEFAULT;
FunctionType.tp_doc = "object that calls vim function";
FunctionType.tp_methods = FunctionMethods;
FunctionType.tp_repr = (reprfunc)FunctionRepr;
#if PY_MAJOR_VERSION >= 3
FunctionType.tp_getattro = (getattrofunc)FunctionGetattro;
#else