[Python-checkins] python/dist/src/Modules pyexpat.c,2.71,2.72

loewis@users.sourceforge.net loewis@users.sourceforge.net
Sun, 04 Aug 2002 01:24:51 -0700


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

Modified Files:
	pyexpat.c 
Log Message:
Add trace_frame. Fixes #534864. Backported to 2.2.


Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.71
retrieving revision 2.72
diff -C2 -d -r2.71 -r2.72
*** pyexpat.c	19 Jul 2002 22:03:03 -0000	2.71
--- pyexpat.c	4 Aug 2002 08:24:49 -0000	2.72
***************
*** 265,268 ****
--- 265,295 ----
  }
  
+ static int
+ trace_frame(PyThreadState *tstate, PyFrameObject *f, int code, PyObject *val)
+ {
+     int result = 0;
+     if (!tstate->use_tracing || tstate->tracing)
+ 	return 0;
+     if (tstate->c_profilefunc != NULL) {
+ 	tstate->tracing++;
+ 	result = tstate->c_profilefunc(tstate->c_profileobj,
+ 				       f, code , val);
+ 	tstate->use_tracing = ((tstate->c_tracefunc != NULL)
+ 			       || (tstate->c_profilefunc != NULL));
+ 	tstate->tracing--;
+ 	if (result)
+ 	    return result;
+     }
+     if (tstate->c_tracefunc != NULL) {
+ 	tstate->tracing++;
+ 	result = tstate->c_tracefunc(tstate->c_traceobj,
+ 				     f, code , val);
+ 	tstate->use_tracing = ((tstate->c_tracefunc != NULL)
+ 			       || (tstate->c_profilefunc != NULL));
+ 	tstate->tracing--;
+     }	
+     return result;
+ }
+ 
  static PyObject*
  call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args)
***************
*** 274,277 ****
--- 301,305 ----
      if (c == NULL)
          return NULL;
+     
      f = PyFrame_New(
                      tstate,			/*back*/
***************
*** 283,289 ****
--- 311,327 ----
          return NULL;
      tstate->frame = f;
+     if (trace_frame(tstate, f, PyTrace_CALL, Py_None)) {
+ 	Py_DECREF(f);
+ 	return NULL;
+     }
      res = PyEval_CallObject(func, args);
      if (res == NULL && tstate->curexc_traceback == NULL)
          PyTraceBack_Here(f);
+     else {
+ 	if (trace_frame(tstate, f, PyTrace_RETURN, res)) {
+ 	    Py_XDECREF(res);
+ 	    res = NULL;
+ 	}
+     }
      tstate->frame = f->f_back;
      Py_DECREF(f);