From e43d33a4db0c0c9afcb70a26f682abfe889e845b Mon Sep 17 00:00:00 2001 From: Amaury Forgeot d'Arc Date: Wed, 2 Jul 2008 20:50:16 +0000 Subject: #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. --- PC/_subprocess.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'PC/_subprocess.c') diff --git a/PC/_subprocess.c b/PC/_subprocess.c index c256ca35d8..77a8a85e47 100644 --- a/PC/_subprocess.c +++ b/PC/_subprocess.c @@ -110,12 +110,6 @@ static PyMethodDef sp_handle_methods[] = { {NULL, NULL} }; -static PyObject* -sp_handle_getattr(sp_handle_object* self, char* name) -{ - return Py_FindMethod(sp_handle_methods, (PyObject*) self, name); -} - static PyObject* sp_handle_as_int(sp_handle_object* self) { @@ -129,14 +123,28 @@ static PyTypeObject sp_handle_type = { "_subprocess_handle", sizeof(sp_handle_object), 0, (destructor) sp_handle_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) sp_handle_getattr,/*tp_getattr*/ + 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &sp_handle_as_number, /*tp_as_number */ 0, /*tp_as_sequence */ 0, /*tp_as_mapping */ - 0 /*tp_hash*/ + 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*/ + sp_handle_methods, /*tp_methods*/ }; /* -------------------------------------------------------------------- */ @@ -560,8 +568,9 @@ PyInit__subprocess() PyObject *m; /* patch up object descriptors */ - Py_TYPE(&sp_handle_type) = &PyType_Type; sp_handle_as_number.nb_int = (unaryfunc) sp_handle_as_int; + if (PyType_Ready(&sp_handle_type) < 0) + return NULL; m = PyModule_Create(&_subprocessmodule); if (m == NULL) -- cgit v1.2.1