Skip to content

Commit 7f85d29

Browse files
committed
updated for version 7.3.422
Problem: Python 3 does not have __members__. Solution: Add "name" and "number" in another way. (lilydjwg)
1 parent 3c70f33 commit 7f85d29

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/if_py_both.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,9 @@ static struct PyMethodDef BufferMethods[] = {
14791479
{"append", BufferAppend, 1, "Append data to Vim buffer" },
14801480
{"mark", BufferMark, 1, "Return (row,col) representing position of named mark" },
14811481
{"range", BufferRange, 1, "Return a range object which represents the part of the given buffer between line numbers s and e" },
1482+
#if PY_VERSION_HEX >= 0x03000000
1483+
{"__dir__", BufferDir, 4, "List its attributes" },
1484+
#endif
14821485
{ NULL, NULL, 0, NULL }
14831486
};
14841487

src/if_python3.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ get_py3_exceptions()
468468
static PyObject *BufferNew (buf_T *);
469469
static PyObject *WindowNew(win_T *);
470470
static PyObject *LineToString(const char *);
471+
static PyObject *BufferDir(PyObject *, PyObject *);
471472

472473
static PyTypeObject RangeType;
473474

@@ -961,12 +962,17 @@ BufferGetattro(PyObject *self, PyObject*nameobj)
961962
return Py_BuildValue("s", this->buf->b_ffname);
962963
else if (strcmp(name, "number") == 0)
963964
return Py_BuildValue("n", this->buf->b_fnum);
964-
else if (strcmp(name,"__members__") == 0)
965-
return Py_BuildValue("[ss]", "name", "number");
966965
else
967966
return PyObject_GenericGetAttr(self, nameobj);
968967
}
969968

969+
static PyObject *
970+
BufferDir(PyObject *self UNUSED, PyObject *args UNUSED)
971+
{
972+
return Py_BuildValue("[sssss]", "name", "number",
973+
"append", "mark", "range");
974+
}
975+
970976
static PyObject *
971977
BufferRepr(PyObject *self)
972978
{

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ static char *(features[]) =
714714

715715
static int included_patches[] =
716716
{ /* Add new patch number below this line */
717+
/**/
718+
422,
717719
/**/
718720
421,
719721
/**/

0 commit comments

Comments
 (0)