[Python-checkins] python/dist/src/Modules _hotshot.c,1.19,1.20
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Wed, 17 Jul 2002 09:15:37 -0700
- Previous message: [Python-checkins] python/dist/src/Lib/test test_hotshot.py,1.6,1.7
- Next message: [Python-checkins] python/dist/src/Modules _sre.c,2.80,2.81 _ssl.c,1.5,1.6 _tkinter.c,1.125,1.126 almodule.c,1.36,1.37 arraymodule.c,2.75,2.76 bsddbmodule.c,1.35,1.36 cPickle.c,2.89,2.90 cmathmodule.c,2.30,2.31 dbmmodule.c,2.30,2.31 dlmodule.c,2.21,2.22 flmodule.c,1.49,1.50 fmmodule.c,1.20,1.21 gdbmmodule.c,2.33,2.34 linuxaudiodev.c,2.18,2.19 md5module.c,2.30,2.31 mpzmodule.c,2.43,2.44 parsermodule.c,2.70,2.71 pcremodule.c,2.31,2.32 pyexpat.c,2.67,2.68 rotormodule.c,2.34,2.35 selectmodule.c,2.64,2.65 shamodule.c,2.19,2.20 socketmodule.c,1.229,1.230 sunaudiodev.c,1.29,1.30 threadmodule.c,2.50,2.51 xreadlinesmodule.c,1.10,1.11 xxmodule.c,2.28,2.29 xxsubtype.c,2.15,2.16 zlibmodule.c,2.62,2.63
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv12160
Modified Files:
_hotshot.c
Log Message:
Some modernization. Get rid of the redundant next() method. Always
assume tp_iter and later fields exist. Use PyObject_GenericGetAttr
instead of providing our own tp_getattr hook.
Index: _hotshot.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** _hotshot.c 30 Jun 2002 15:26:09 -0000 1.19
--- _hotshot.c 17 Jul 2002 16:15:35 -0000 1.20
***************
*** 121,129 ****
}
- #if Py_TPFLAGS_HAVE_ITER
- /* This is only used if the interpreter has iterator support; the
- * iternext handler is also used as a helper for other functions, so
- * does not need to be included in this conditional section.
- */
static PyObject *
logreader_tp_iter(LogReaderObject *self)
--- 121,124 ----
***************
*** 132,136 ****
return (PyObject *) self;
}
- #endif
--- 127,130 ----
***************
*** 523,547 ****
}
- PyDoc_STRVAR(next__doc__,
- "next() -> event-info\n"
- "Return the next event record from the log file.");
-
- static PyObject *
- logreader_next(LogReaderObject *self, PyObject *args)
- {
- PyObject *result = NULL;
-
- if (PyArg_ParseTuple(args, ":next")) {
- result = logreader_tp_iternext(self);
- /* XXX return None if there's nothing left */
- /* tp_iternext does the right thing, though */
- if (result == NULL && !PyErr_Occurred()) {
- result = Py_None;
- Py_INCREF(result);
- }
- }
- return result;
- }
-
static void
do_stop(ProfilerObject *self);
--- 517,520 ----
***************
*** 1182,1189 ****
}
- /* Always use METH_VARARGS even though some of these could be METH_NOARGS;
- * this allows us to maintain compatibility with Python versions < 2.2
- * more easily, requiring only the changes to the dispatcher to be made.
- */
static PyMethodDef profiler_methods[] = {
{"addinfo", (PyCFunction)profiler_addinfo, METH_VARARGS, addinfo__doc__},
--- 1155,1158 ----
***************
*** 1196,1204 ****
};
! /* Use a table even though there's only one "simple" member; this allows
! * __members__ and therefore dir() to work.
! */
! static struct memberlist profiler_members[] = {
! {"closed", T_INT, -1, READONLY},
{"frametimings", T_LONG, offsetof(ProfilerObject, linetimings), READONLY},
{"lineevents", T_LONG, offsetof(ProfilerObject, lineevents), READONLY},
--- 1165,1169 ----
};
! static PyMemberDef profiler_members[] = {
{"frametimings", T_LONG, offsetof(ProfilerObject, linetimings), READONLY},
{"lineevents", T_LONG, offsetof(ProfilerObject, lineevents), READONLY},
***************
*** 1208,1228 ****
static PyObject *
! profiler_getattr(ProfilerObject *self, char *name)
{
! PyObject *result;
! if (strcmp(name, "closed") == 0) {
! result = (self->logfp == NULL) ? Py_True : Py_False;
! Py_INCREF(result);
! }
! else {
! result = PyMember_Get((char *)self, profiler_members, name);
! if (result == NULL) {
! PyErr_Clear();
! result = Py_FindMethod(profiler_methods, (PyObject *)self, name);
! }
! }
return result;
}
PyDoc_STRVAR(profiler_object__doc__,
--- 1173,1188 ----
static PyObject *
! profiler_get_closed(ProfilerObject *self, void *closure)
{
! PyObject *result = (self->logfp == NULL) ? Py_True : Py_False;
! Py_INCREF(result);
return result;
}
+ static PyGetSetDef profiler_getsets[] = {
+ {"closed", (getter)profiler_get_closed, NULL},
+ {NULL}
+ };
+
PyDoc_STRVAR(profiler_object__doc__,
***************
*** 1252,1256 ****
(destructor)profiler_dealloc, /* tp_dealloc */
0, /* tp_print */
! (getattrfunc)profiler_getattr, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
--- 1212,1216 ----
(destructor)profiler_dealloc, /* tp_dealloc */
0, /* tp_print */
! 0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
***************
*** 1262,1270 ****
0, /* tp_call */
0, /* tp_str */
! 0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
profiler_object__doc__, /* tp_doc */
};
--- 1222,1243 ----
0, /* tp_call */
0, /* tp_str */
! PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
profiler_object__doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ profiler_methods, /* tp_methods */
+ profiler_members, /* tp_members */
+ profiler_getsets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
};
***************
*** 1273,1290 ****
{"close", (PyCFunction)logreader_close, METH_VARARGS,
logreader_close__doc__},
- {"next", (PyCFunction)logreader_next, METH_VARARGS,
- next__doc__},
{NULL, NULL}
};
! static PyObject *
! logreader_getattr(LogReaderObject *self, char *name)
! {
! if (strcmp(name, "info") == 0) {
! Py_INCREF(self->info);
! return self->info;
! }
! return Py_FindMethod(logreader_methods, (PyObject *)self, name);
! }
--- 1246,1256 ----
{"close", (PyCFunction)logreader_close, METH_VARARGS,
logreader_close__doc__},
{NULL, NULL}
};
! static PyMemberDef logreader_members[] = {
! {"info", T_OBJECT, offsetof(LogReaderObject, info), RO},
! {NULL}
! };
***************
*** 1314,1318 ****
(destructor)logreader_dealloc, /* tp_dealloc */
0, /* tp_print */
! (getattrfunc)logreader_getattr, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
--- 1280,1284 ----
(destructor)logreader_dealloc, /* tp_dealloc */
0, /* tp_print */
! 0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
***************
*** 1324,1333 ****
0, /* tp_call */
0, /* tp_str */
! 0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
logreader__doc__, /* tp_doc */
- #if Py_TPFLAGS_HAVE_ITER
0, /* tp_traverse */
0, /* tp_clear */
--- 1290,1298 ----
0, /* tp_call */
0, /* tp_str */
! PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
logreader__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
***************
*** 1336,1340 ****
(getiterfunc)logreader_tp_iter, /* tp_iter */
(iternextfunc)logreader_tp_iternext,/* tp_iternext */
! #endif
};
--- 1301,1311 ----
(getiterfunc)logreader_tp_iter, /* tp_iter */
(iternextfunc)logreader_tp_iternext,/* tp_iternext */
! logreader_methods, /* tp_methods */
! logreader_members, /* tp_members */
! 0, /* tp_getset */
! 0, /* tp_base */
! 0, /* tp_dict */
! 0, /* tp_descr_get */
! 0, /* tp_descr_set */
};
- Previous message: [Python-checkins] python/dist/src/Lib/test test_hotshot.py,1.6,1.7
- Next message: [Python-checkins] python/dist/src/Modules _sre.c,2.80,2.81 _ssl.c,1.5,1.6 _tkinter.c,1.125,1.126 almodule.c,1.36,1.37 arraymodule.c,2.75,2.76 bsddbmodule.c,1.35,1.36 cPickle.c,2.89,2.90 cmathmodule.c,2.30,2.31 dbmmodule.c,2.30,2.31 dlmodule.c,2.21,2.22 flmodule.c,1.49,1.50 fmmodule.c,1.20,1.21 gdbmmodule.c,2.33,2.34 linuxaudiodev.c,2.18,2.19 md5module.c,2.30,2.31 mpzmodule.c,2.43,2.44 parsermodule.c,2.70,2.71 pcremodule.c,2.31,2.32 pyexpat.c,2.67,2.68 rotormodule.c,2.34,2.35 selectmodule.c,2.64,2.65 shamodule.c,2.19,2.20 socketmodule.c,1.229,1.230 sunaudiodev.c,1.29,1.30 threadmodule.c,2.50,2.51 xreadlinesmodule.c,1.10,1.11 xxmodule.c,2.28,2.29 xxsubtype.c,2.15,2.16 zlibmodule.c,2.62,2.63
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]