comparison src/if_python3.c @ 4599:89bec74fd793 v7.3.1047

updated for version 7.3.1047 Problem: Python: dir() does not work properly. Solution: Python patch 8. Add __dir__ method to all objects with custom tp_getattr supplemented by __members__ attribute for at least python-2* versions. __members__ is not mentioned in python-3* dir() output even if it is accessible. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Wed, 29 May 2013 22:36:10 +0200
parents 0cf552b325b5
children 548b889fe3cf
comparison
equal deleted inserted replaced
4598:18914d6c96c8 4599:89bec74fd793
664 call_PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems) 664 call_PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
665 { 665 {
666 return PyType_GenericAlloc(type,nitems); 666 return PyType_GenericAlloc(type,nitems);
667 } 667 }
668 668
669 static PyObject *BufferDir(PyObject *);
670 static PyObject *OutputGetattro(PyObject *, PyObject *); 669 static PyObject *OutputGetattro(PyObject *, PyObject *);
671 static int OutputSetattro(PyObject *, PyObject *, PyObject *); 670 static int OutputSetattro(PyObject *, PyObject *, PyObject *);
672 static PyObject *BufferGetattro(PyObject *, PyObject *); 671 static PyObject *BufferGetattro(PyObject *, PyObject *);
673 static int BufferSetattro(PyObject *, PyObject *, PyObject *); 672 static int BufferSetattro(PyObject *, PyObject *, PyObject *);
674 static PyObject *TabPageGetattro(PyObject *, PyObject *); 673 static PyObject *TabPageGetattro(PyObject *, PyObject *);
1092 GET_ATTR_STRING(name, nameobj); 1091 GET_ATTR_STRING(name, nameobj);
1093 1092
1094 return BufferSetattr((BufferObject *)(self), name, val); 1093 return BufferSetattr((BufferObject *)(self), name, val);
1095 } 1094 }
1096 1095
1097 static PyObject *
1098 BufferDir(PyObject *self UNUSED)
1099 {
1100 return Py_BuildValue("[ssssssss]",
1101 "name", "number", "vars", "options", "valid",
1102 "append", "mark", "range");
1103 }
1104
1105 /******************/ 1096 /******************/
1106 1097
1107 static PyObject * 1098 static PyObject *
1108 BufferSubscript(PyObject *self, PyObject* idx) 1099 BufferSubscript(PyObject *self, PyObject* idx)
1109 { 1100 {
1366 /* Current items object - Implementation 1357 /* Current items object - Implementation
1367 */ 1358 */
1368 static PyObject * 1359 static PyObject *
1369 CurrentGetattro(PyObject *self, PyObject *nameobj) 1360 CurrentGetattro(PyObject *self, PyObject *nameobj)
1370 { 1361 {
1362 PyObject *r;
1371 GET_ATTR_STRING(name, nameobj); 1363 GET_ATTR_STRING(name, nameobj);
1372 return CurrentGetattr(self, name); 1364 if (!(r = CurrentGetattr(self, name)))
1365 return PyObject_GenericGetAttr(self, nameobj);
1366 return r;
1373 } 1367 }
1374 1368
1375 static int 1369 static int
1376 CurrentSetattro(PyObject *self, PyObject *nameobj, PyObject *value) 1370 CurrentSetattro(PyObject *self, PyObject *nameobj, PyObject *value)
1377 { 1371 {