diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-05-29 22:36:10 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-05-29 22:36:10 +0200 |
commit | dd8aca664d9768614d18cebec84badc3ecad3af5 (patch) | |
tree | 6002f0821e725f7829f73bc05336f4fc4ca376a3 /src/if_python.c | |
parent | 432b09c84dc6daf0b7ca8dac986bc0b1faf899d7 (diff) | |
download | vim-git-dd8aca664d9768614d18cebec84badc3ecad3af5.tar.gz |
updated for version 7.3.1047v7.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)
Diffstat (limited to 'src/if_python.c')
-rw-r--r-- | src/if_python.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/if_python.c b/src/if_python.c index f8e72f5fc..889ff05d3 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -1066,6 +1066,8 @@ OutputGetattr(PyObject *self, char *name) { if (strcmp(name, "softspace") == 0) return PyInt_FromLong(((OutputObject *)(self))->softspace); + else if (strcmp(name, "__members__") == 0) + return ObjectDir(NULL, OutputAttrs); return Py_FindMethod(OutputMethods, self, name); } @@ -1177,6 +1179,8 @@ RangeGetattr(PyObject *self, char *name) return Py_BuildValue(Py_ssize_t_fmt, ((RangeObject *)(self))->start - 1); else if (strcmp(name, "end") == 0) return Py_BuildValue(Py_ssize_t_fmt, ((RangeObject *)(self))->end - 1); + else if (strcmp(name, "__members__") == 0) + return ObjectDir(NULL, RangeAttrs); else return Py_FindMethod(RangeMethods, self, name); } @@ -1396,6 +1400,8 @@ DictionaryGetattr(PyObject *self, char *name) return PyInt_FromLong(this->dict->dv_lock); else if (strcmp(name, "scope") == 0) return PyInt_FromLong(this->dict->dv_scope); + else if (strcmp(name, "__members__") == 0) + return ObjectDir(NULL, DictionaryAttrs); return Py_FindMethod(DictionaryMethods, self, name); } @@ -1420,6 +1426,8 @@ ListGetattr(PyObject *self, char *name) { if (strcmp(name, "locked") == 0) return PyInt_FromLong(((ListObject *)(self))->list->lv_lock); + else if (strcmp(name, "__members__") == 0) + return ObjectDir(NULL, ListAttrs); return Py_FindMethod(ListMethods, self, name); } @@ -1431,6 +1439,8 @@ FunctionGetattr(PyObject *self, char *name) if (strcmp(name, "name") == 0) return PyString_FromString((char *)(this->name)); + else if (strcmp(name, "__members__") == 0) + return ObjectDir(NULL, FunctionAttrs); else return Py_FindMethod(FunctionMethods, self, name); } |