@@ -120,18 +120,12 @@ logreader_close(LogReaderObject *self, PyObject *args)
120120 return result ;
121121}
122122
123- #if Py_TPFLAGS_HAVE_ITER
124- /* This is only used if the interpreter has iterator support; the
125- * iternext handler is also used as a helper for other functions, so
126- * does not need to be included in this conditional section.
127- */
128123static PyObject *
129124logreader_tp_iter (LogReaderObject * self )
130125{
131126 Py_INCREF (self );
132127 return (PyObject * ) self ;
133128}
134- #endif
135129
136130
137131/* Log File Format
@@ -522,27 +516,6 @@ logreader_sq_item(LogReaderObject *self, int index)
522516 return result ;
523517}
524518
525- PyDoc_STRVAR (next__doc__ ,
526- "next() -> event-info\n"
527- "Return the next event record from the log file." );
528-
529- static PyObject *
530- logreader_next (LogReaderObject * self , PyObject * args )
531- {
532- PyObject * result = NULL ;
533-
534- if (PyArg_ParseTuple (args , ":next" )) {
535- result = logreader_tp_iternext (self );
536- /* XXX return None if there's nothing left */
537- /* tp_iternext does the right thing, though */
538- if (result == NULL && !PyErr_Occurred ()) {
539- result = Py_None ;
540- Py_INCREF (result );
541- }
542- }
543- return result ;
544- }
545-
546519static void
547520do_stop (ProfilerObject * self );
548521
@@ -1181,10 +1154,6 @@ profiler_dealloc(ProfilerObject *self)
11811154 PyObject_Del ((PyObject * )self );
11821155}
11831156
1184- /* Always use METH_VARARGS even though some of these could be METH_NOARGS;
1185- * this allows us to maintain compatibility with Python versions < 2.2
1186- * more easily, requiring only the changes to the dispatcher to be made.
1187- */
11881157static PyMethodDef profiler_methods [] = {
11891158 {"addinfo" , (PyCFunction )profiler_addinfo , METH_VARARGS , addinfo__doc__ },
11901159 {"close" , (PyCFunction )profiler_close , METH_VARARGS , close__doc__ },
@@ -1195,35 +1164,26 @@ static PyMethodDef profiler_methods[] = {
11951164 {NULL , NULL }
11961165};
11971166
1198- /* Use a table even though there's only one "simple" member; this allows
1199- * __members__ and therefore dir() to work.
1200- */
1201- static struct memberlist profiler_members [] = {
1202- {"closed" , T_INT , -1 , READONLY },
1167+ static PyMemberDef profiler_members [] = {
12031168 {"frametimings" , T_LONG , offsetof(ProfilerObject , linetimings ), READONLY },
12041169 {"lineevents" , T_LONG , offsetof(ProfilerObject , lineevents ), READONLY },
12051170 {"linetimings" , T_LONG , offsetof(ProfilerObject , linetimings ), READONLY },
12061171 {NULL }
12071172};
12081173
12091174static PyObject *
1210- profiler_getattr (ProfilerObject * self , char * name )
1175+ profiler_get_closed (ProfilerObject * self , void * closure )
12111176{
1212- PyObject * result ;
1213- if (strcmp (name , "closed" ) == 0 ) {
1214- result = (self -> logfp == NULL ) ? Py_True : Py_False ;
1215- Py_INCREF (result );
1216- }
1217- else {
1218- result = PyMember_Get ((char * )self , profiler_members , name );
1219- if (result == NULL ) {
1220- PyErr_Clear ();
1221- result = Py_FindMethod (profiler_methods , (PyObject * )self , name );
1222- }
1223- }
1177+ PyObject * result = (self -> logfp == NULL ) ? Py_True : Py_False ;
1178+ Py_INCREF (result );
12241179 return result ;
12251180}
12261181
1182+ static PyGetSetDef profiler_getsets [] = {
1183+ {"closed" , (getter )profiler_get_closed , NULL },
1184+ {NULL }
1185+ };
1186+
12271187
12281188PyDoc_STRVAR (profiler_object__doc__ ,
12291189"High-performance profiler object.\n"
@@ -1251,7 +1211,7 @@ static PyTypeObject ProfilerType = {
12511211 0 , /* tp_itemsize */
12521212 (destructor )profiler_dealloc , /* tp_dealloc */
12531213 0 , /* tp_print */
1254- ( getattrfunc ) profiler_getattr , /* tp_getattr */
1214+ 0 , /* tp_getattr */
12551215 0 , /* tp_setattr */
12561216 0 , /* tp_compare */
12571217 0 , /* tp_repr */
@@ -1261,31 +1221,37 @@ static PyTypeObject ProfilerType = {
12611221 0 , /* tp_hash */
12621222 0 , /* tp_call */
12631223 0 , /* tp_str */
1264- 0 , /* tp_getattro */
1224+ PyObject_GenericGetAttr , /* tp_getattro */
12651225 0 , /* tp_setattro */
12661226 0 , /* tp_as_buffer */
12671227 Py_TPFLAGS_DEFAULT , /* tp_flags */
12681228 profiler_object__doc__ , /* tp_doc */
1229+ 0 , /* tp_traverse */
1230+ 0 , /* tp_clear */
1231+ 0 , /* tp_richcompare */
1232+ 0 , /* tp_weaklistoffset */
1233+ 0 , /* tp_iter */
1234+ 0 , /* tp_iternext */
1235+ profiler_methods , /* tp_methods */
1236+ profiler_members , /* tp_members */
1237+ profiler_getsets , /* tp_getset */
1238+ 0 , /* tp_base */
1239+ 0 , /* tp_dict */
1240+ 0 , /* tp_descr_get */
1241+ 0 , /* tp_descr_set */
12691242};
12701243
12711244
12721245static PyMethodDef logreader_methods [] = {
12731246 {"close" , (PyCFunction )logreader_close , METH_VARARGS ,
12741247 logreader_close__doc__ },
1275- {"next" , (PyCFunction )logreader_next , METH_VARARGS ,
1276- next__doc__ },
12771248 {NULL , NULL }
12781249};
12791250
1280- static PyObject *
1281- logreader_getattr (LogReaderObject * self , char * name )
1282- {
1283- if (strcmp (name , "info" ) == 0 ) {
1284- Py_INCREF (self -> info );
1285- return self -> info ;
1286- }
1287- return Py_FindMethod (logreader_methods , (PyObject * )self , name );
1288- }
1251+ static PyMemberDef logreader_members [] = {
1252+ {"info" , T_OBJECT , offsetof(LogReaderObject , info ), RO },
1253+ {NULL }
1254+ };
12891255
12901256
12911257PyDoc_STRVAR (logreader__doc__ ,
@@ -1313,7 +1279,7 @@ static PyTypeObject LogReaderType = {
13131279 0 , /* tp_itemsize */
13141280 (destructor )logreader_dealloc , /* tp_dealloc */
13151281 0 , /* tp_print */
1316- ( getattrfunc ) logreader_getattr , /* tp_getattr */
1282+ 0 , /* tp_getattr */
13171283 0 , /* tp_setattr */
13181284 0 , /* tp_compare */
13191285 0 , /* tp_repr */
@@ -1323,19 +1289,24 @@ static PyTypeObject LogReaderType = {
13231289 0 , /* tp_hash */
13241290 0 , /* tp_call */
13251291 0 , /* tp_str */
1326- 0 , /* tp_getattro */
1292+ PyObject_GenericGetAttr , /* tp_getattro */
13271293 0 , /* tp_setattro */
13281294 0 , /* tp_as_buffer */
13291295 Py_TPFLAGS_DEFAULT , /* tp_flags */
13301296 logreader__doc__ , /* tp_doc */
1331- #if Py_TPFLAGS_HAVE_ITER
13321297 0 , /* tp_traverse */
13331298 0 , /* tp_clear */
13341299 0 , /* tp_richcompare */
13351300 0 , /* tp_weaklistoffset */
13361301 (getiterfunc )logreader_tp_iter , /* tp_iter */
13371302 (iternextfunc )logreader_tp_iternext ,/* tp_iternext */
1338- #endif
1303+ logreader_methods , /* tp_methods */
1304+ logreader_members , /* tp_members */
1305+ 0 , /* tp_getset */
1306+ 0 , /* tp_base */
1307+ 0 , /* tp_dict */
1308+ 0 , /* tp_descr_get */
1309+ 0 , /* tp_descr_set */
13391310};
13401311
13411312static PyObject *
0 commit comments