[Python-checkins] CVS: python/dist/src/Python ceval.c,2.279,2.280 sysmodule.c,2.92,2.93

Fred L. Drake fdrake@users.sourceforge.net
Thu, 04 Oct 2001 07:48:44 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv28459/Python

Modified Files:
	ceval.c sysmodule.c 
Log Message:
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.


Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.279
retrieving revision 2.280
diff -C2 -d -r2.279 -r2.280
*** ceval.c	2001/09/30 05:58:42	2.279
--- ceval.c	2001/10/04 14:48:42	2.280
***************
*** 2199,2210 ****
  			PyTraceBack_Here(f);
  
! 			if (tstate->use_tracing) {
! 				if (tstate->c_tracefunc)
! 					call_exc_trace(tstate->c_tracefunc,
! 						       tstate->c_traceobj, f);
! 				if (tstate->c_profilefunc)
! 					call_exc_trace(tstate->c_profilefunc,
! 						       tstate->c_profileobj,f);
! 			}
  		}
  
--- 2199,2205 ----
  			PyTraceBack_Here(f);
  
! 			if (tstate->c_tracefunc != NULL)
! 				call_exc_trace(tstate->c_tracefunc,
! 					       tstate->c_traceobj, f);
  		}
  
***************
*** 2302,2307 ****
  			}
  		}
! 		if (tstate->c_profilefunc
! 		    && (why == WHY_RETURN || why == WHY_YIELD)) {
  			if (call_trace(tstate->c_profilefunc,
  				       tstate->c_profileobj, f,
--- 2297,2301 ----
  			}
  		}
! 		if (tstate->c_profilefunc) {
  			if (call_trace(tstate->c_profilefunc,
  				       tstate->c_profileobj, f,

Index: sysmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v
retrieving revision 2.92
retrieving revision 2.93
diff -C2 -d -r2.92 -r2.93
*** sysmodule.c	2001/08/17 18:39:25	2.92
--- sysmodule.c	2001/10/04 14:48:42	2.93
***************
*** 261,264 ****
--- 261,266 ----
  	PyObject *result;
  
+ 	if (arg == NULL)
+ 		arg = Py_None;
  	result = call_trampoline(tstate, self, frame, what, arg);
  	if (result == NULL) {