comparison Python/sysmodule.c @ 20247:a4d328d50897 legacy-trunk

Rationalize the events passed to the profiler (no changes for the tracer). The profiler does not need to know anything about the exception state, so we no longer call it when an exception is raised. We do, however, make sure we *always* call the profiler when we exit a frame. This ensures that timing events are more easily isolated by a profiler and finally clauses that do a lot of work don't have their time mis-allocated. When an exception is propogated out of the frame, the C callback for the profiler now receives a PyTrace_RETURN event with an arg of NULL; the Python-level profile hook function will see a 'return' event with an arg of None. This means that from Python it is impossible for the profiler to determine if the frame exited with an exception or if it returned None, but this doesn't matter for profiling. A C-based profiler could tell the difference, but this doesn't seem important. ceval.c:eval_frame(): Simplify the code in two places so that the profiler is called for every exit from a frame and not for exceptions. sysmodule.c:profile_trampoline(): Make sure we don't expose Python code to NULL; use None instead.
author Fred Drake <fdrake@acm.org>
date Thu, 04 Oct 2001 14:48:42 +0000
parents 7257e87e0720
children 7344687bf2c0
comparison
equal deleted inserted replaced
20246:f3b3fd5abfa6 20247:a4d328d50897
258 int what, PyObject *arg) 258 int what, PyObject *arg)
259 { 259 {
260 PyThreadState *tstate = frame->f_tstate; 260 PyThreadState *tstate = frame->f_tstate;
261 PyObject *result; 261 PyObject *result;
262 262
263 if (arg == NULL)
264 arg = Py_None;
263 result = call_trampoline(tstate, self, frame, what, arg); 265 result = call_trampoline(tstate, self, frame, what, arg);
264 if (result == NULL) { 266 if (result == NULL) {
265 PyEval_SetProfile(NULL, NULL); 267 PyEval_SetProfile(NULL, NULL);
266 return -1; 268 return -1;
267 } 269 }