diff 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
line wrap: on
line diff
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -666,7 +666,6 @@ call_PyType_GenericAlloc(PyTypeObject *t
     return PyType_GenericAlloc(type,nitems);
 }
 
-static PyObject *BufferDir(PyObject *);
 static PyObject *OutputGetattro(PyObject *, PyObject *);
 static int OutputSetattro(PyObject *, PyObject *, PyObject *);
 static PyObject *BufferGetattro(PyObject *, PyObject *);
@@ -1094,14 +1093,6 @@ BufferSetattro(PyObject *self, PyObject 
     return BufferSetattr((BufferObject *)(self), name, val);
 }
 
-    static PyObject *
-BufferDir(PyObject *self UNUSED)
-{
-    return Py_BuildValue("[ssssssss]",
-	    "name", "number", "vars", "options", "valid",
-	    "append", "mark", "range");
-}
-
 /******************/
 
     static PyObject *
@@ -1368,8 +1359,11 @@ static PySequenceMethods WinListAsSeq = 
     static PyObject *
 CurrentGetattro(PyObject *self, PyObject *nameobj)
 {
+    PyObject	*r;
     GET_ATTR_STRING(name, nameobj);
-    return CurrentGetattr(self, name);
+    if (!(r = CurrentGetattr(self, name)))
+	return PyObject_GenericGetAttr(self, nameobj);
+    return r;
 }
 
     static int