Mercurial > vim
changeset 3310:60f6df978a41 v7.3.422
updated for version 7.3.422
Problem: Python 3 does not have __members__.
Solution: Add "name" and "number" in another way. (lilydjwg)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 04 Feb 2012 20:17:26 +0100 |
parents | d3cf98aa1619 |
children | 54d1536a1c8b |
files | src/if_py_both.h src/if_python3.c src/version.c |
diffstat | 3 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -1479,6 +1479,9 @@ static struct PyMethodDef BufferMethods[ {"append", BufferAppend, 1, "Append data to Vim buffer" }, {"mark", BufferMark, 1, "Return (row,col) representing position of named mark" }, {"range", BufferRange, 1, "Return a range object which represents the part of the given buffer between line numbers s and e" }, +#if PY_VERSION_HEX >= 0x03000000 + {"__dir__", BufferDir, 4, "List its attributes" }, +#endif { NULL, NULL, 0, NULL } };
--- a/src/if_python3.c +++ b/src/if_python3.c @@ -468,6 +468,7 @@ get_py3_exceptions() static PyObject *BufferNew (buf_T *); static PyObject *WindowNew(win_T *); static PyObject *LineToString(const char *); +static PyObject *BufferDir(PyObject *, PyObject *); static PyTypeObject RangeType; @@ -961,13 +962,18 @@ BufferGetattro(PyObject *self, PyObject* return Py_BuildValue("s", this->buf->b_ffname); else if (strcmp(name, "number") == 0) return Py_BuildValue("n", this->buf->b_fnum); - else if (strcmp(name,"__members__") == 0) - return Py_BuildValue("[ss]", "name", "number"); else return PyObject_GenericGetAttr(self, nameobj); } static PyObject * +BufferDir(PyObject *self UNUSED, PyObject *args UNUSED) +{ + return Py_BuildValue("[sssss]", "name", "number", + "append", "mark", "range"); +} + + static PyObject * BufferRepr(PyObject *self) { static char repr[100];