diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-11 06:39:53 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-11 06:39:53 (GMT) |
commit | 8dfc4a9baca7b039048b6e1dab3e4eb09f7af463 (patch) | |
tree | c755a631b7c3736811c173469a63d570124fe0d4 /Modules | |
parent | 32ca442b13ecbd50e9b4a55b97ca12061ef13b5f (diff) | |
download | cpython-8dfc4a9baca7b039048b6e1dab3e4eb09f7af463.zip cpython-8dfc4a9baca7b039048b6e1dab3e4eb09f7af463.tar.gz cpython-8dfc4a9baca7b039048b6e1dab3e4eb09f7af463.tar.bz2 |
Remove support for __members__ and __methods__. There still might be
some cleanup to do on this. Particularly in Python/traceback.c with
getting rid of the getattr if possible and Demo/*metaclasses/Enum.py.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/pyexpat.c | 74 |
1 files changed, 46 insertions, 28 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 8638b2e..02c5d40 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1400,6 +1400,12 @@ xmlparse_getattr(xmlparseobject *self, char *name) } } + return Py_FindMethod(xmlparse_methods, (PyObject *)self, name); +} + +static PyObject * +xmlparse_dir(PyObject *self, PyObject* noargs) +{ #define APPEND(list, str) \ do { \ PyObject *o = PyString_FromString(str); \ @@ -1408,36 +1414,39 @@ xmlparse_getattr(xmlparseobject *self, char *name) Py_XDECREF(o); \ } while (0) - if (strcmp(name, "__members__") == 0) { - int i; - PyObject *rc = PyList_New(0); - if (!rc) - return NULL; - for (i = 0; handler_info[i].name != NULL; i++) { - PyObject *o = get_handler_name(&handler_info[i]); - if (o != NULL) - PyList_Append(rc, o); - Py_XDECREF(o); - } - APPEND(rc, "ErrorCode"); - APPEND(rc, "ErrorLineNumber"); - APPEND(rc, "ErrorColumnNumber"); - APPEND(rc, "ErrorByteIndex"); - APPEND(rc, "CurrentLineNumber"); - APPEND(rc, "CurrentColumnNumber"); - APPEND(rc, "CurrentByteIndex"); - APPEND(rc, "buffer_size"); - APPEND(rc, "buffer_text"); - APPEND(rc, "buffer_used"); - APPEND(rc, "namespace_prefixes"); - APPEND(rc, "ordered_attributes"); - APPEND(rc, "specified_attributes"); - APPEND(rc, "intern"); + int i; + PyObject *rc = PyList_New(0); + if (!rc) + return NULL; + for (i = 0; handler_info[i].name != NULL; i++) { + PyObject *o = get_handler_name(&handler_info[i]); + if (o != NULL) + PyList_Append(rc, o); + Py_XDECREF(o); + } + APPEND(rc, "ErrorCode"); + APPEND(rc, "ErrorLineNumber"); + APPEND(rc, "ErrorColumnNumber"); + APPEND(rc, "ErrorByteIndex"); + APPEND(rc, "CurrentLineNumber"); + APPEND(rc, "CurrentColumnNumber"); + APPEND(rc, "CurrentByteIndex"); + APPEND(rc, "buffer_size"); + APPEND(rc, "buffer_text"); + APPEND(rc, "buffer_used"); + APPEND(rc, "namespace_prefixes"); + APPEND(rc, "ordered_attributes"); + APPEND(rc, "specified_attributes"); + APPEND(rc, "intern"); #undef APPEND - return rc; + + if (PyErr_Occurred()) { + Py_DECREF(rc); + rc = NULL; } - return Py_FindMethod(xmlparse_methods, (PyObject *)self, name); + + return rc; } static int @@ -1560,6 +1569,10 @@ xmlparse_clear(xmlparseobject *op) PyDoc_STRVAR(Xmlparsetype__doc__, "XML parser"); +static PyMethodDef xmlparse_tp_methods[] = { + {"__dir__", xmlparse_dir, METH_NOARGS} +}; + static PyTypeObject Xmlparsetype = { PyVarObject_HEAD_INIT(NULL, 0) "pyexpat.xmlparser", /*tp_name*/ @@ -1588,7 +1601,12 @@ static PyTypeObject Xmlparsetype = { #endif Xmlparsetype__doc__, /* tp_doc - Documentation string */ (traverseproc)xmlparse_traverse, /* tp_traverse */ - (inquiry)xmlparse_clear /* tp_clear */ + (inquiry)xmlparse_clear, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + xmlparse_tp_methods /* tp_methods */ }; /* End of code for xmlparser objects */ |