diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-07-02 20:50:16 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-07-02 20:50:16 (GMT) |
commit | e43d33a4db0c0c9afcb70a26f682abfe889e845b (patch) | |
tree | 47197bd06fa88bf96cef5f673018d20887fa301c /Modules/selectmodule.c | |
parent | 4118174315f4cba03208886af868fe31f1cd5b9d (diff) | |
download | cpython-e43d33a4db0c0c9afcb70a26f682abfe889e845b.zip cpython-e43d33a4db0c0c9afcb70a26f682abfe889e845b.tar.gz cpython-e43d33a4db0c0c9afcb70a26f682abfe889e845b.tar.bz2 |
#3247 Get rid of Py_FindMethod; use tp_members instead.
Otherwise dir(_sre.SRE_Match) returns an empty list.
First step: handle most occurrences, remove tp_getattr and fill the tp_methods and tp_members slots.
Add some test about attribute access.
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r-- | Modules/selectmodule.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index f1c71e4..daabf03 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -625,12 +625,6 @@ poll_dealloc(pollObject *self) PyObject_Del(self); } -static PyObject * -poll_getattr(pollObject *self, char *name) -{ - return Py_FindMethod(poll_methods, (PyObject *)self, name); -} - static PyTypeObject poll_Type = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ @@ -641,7 +635,7 @@ static PyTypeObject poll_Type = { /* methods */ (destructor)poll_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc)poll_getattr, /*tp_getattr*/ + 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ @@ -649,6 +643,20 @@ static PyTypeObject poll_Type = { 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + poll_methods, /*tp_methods*/ }; PyDoc_STRVAR(poll_doc, @@ -1764,7 +1772,8 @@ PyInit_select(void) #else { #endif - Py_TYPE(&poll_Type) = &PyType_Type; + if (PyType_Ready(&poll_Type) < 0) + return NULL; PyModule_AddIntConstant(m, "POLLIN", POLLIN); PyModule_AddIntConstant(m, "POLLPRI", POLLPRI); PyModule_AddIntConstant(m, "POLLOUT", POLLOUT); |