[Python-checkins] python/dist/src/Python ceval.c,2.370,2.371

arigo at users.sourceforge.net arigo at users.sourceforge.net
Tue Oct 28 07:05:50 EST 2003


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

Modified Files:
	ceval.c 
Log Message:
Deleting cyclic object comparison.
SF patch 825639
http://mail.python.org/pipermail/python-dev/2003-October/039445.html



Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.370
retrieving revision 2.371
diff -C2 -d -r2.370 -r2.371
*** ceval.c	25 Oct 2003 14:33:09 -0000	2.370
--- ceval.c	28 Oct 2003 12:05:48 -0000	2.371
***************
*** 498,501 ****
--- 498,502 ----
  
  static int recursion_limit = 1000;
+ int _Py_CheckRecursionLimit = 1000;
  
  int
***************
*** 509,514 ****
--- 510,545 ----
  {
  	recursion_limit = new_limit;
+         _Py_CheckRecursionLimit = recursion_limit;
+ }
+ 
+ /* the macro Py_EnterRecursiveCall() only calls _Py_CheckRecursiveCall()
+    if the recursion_depth reaches _Py_CheckRecursionLimit.
+    If USE_STACKCHECK, the macro decrements _Py_CheckRecursionLimit
+    to guarantee that _Py_CheckRecursiveCall() is regularly called.
+    Without USE_STACKCHECK, there is no need for this. */
+ int
+ _Py_CheckRecursiveCall(char *where)
+ {
+ 	PyThreadState *tstate = PyThreadState_GET();
+ 
+ #ifdef USE_STACKCHECK
+ 	if (PyOS_CheckStack()) {
+ 		--tstate->recursion_depth;
+ 		PyErr_SetString(PyExc_MemoryError, "Stack overflow");
+ 		return -1;
+ 	}
+ #endif
+ 	if (tstate->recursion_depth > recursion_limit) {
+ 		--tstate->recursion_depth;
+ 		PyErr_Format(PyExc_RuntimeError,
+ 			     "maximum recursion depth exceeded%s",
+ 			     where);
+ 		return -1;
+ 	}
+         _Py_CheckRecursionLimit = recursion_limit;
+ 	return 0;
  }
  
+ 
  /* Status code for main loop (reason for stack unwind) */
  
***************
*** 675,693 ****
  		return NULL;
  
- #ifdef USE_STACKCHECK
- 	if (tstate->recursion_depth%10 == 0 && PyOS_CheckStack()) {
- 		PyErr_SetString(PyExc_MemoryError, "Stack overflow");
- 		return NULL;
- 	}
- #endif
- 
  	/* push frame */
! 	if (++tstate->recursion_depth > recursion_limit) {
! 		--tstate->recursion_depth;
! 		PyErr_SetString(PyExc_RuntimeError,
! 				"maximum recursion depth exceeded");
! 		tstate->frame = f->f_back;
  		return NULL;
- 	}
  
  	tstate->frame = f;
--- 706,712 ----
  		return NULL;
  
  	/* push frame */
! 	if (Py_EnterRecursiveCall(""))
  		return NULL;
  
  	tstate->frame = f;
***************
*** 711,717 ****
  				       f, PyTrace_CALL, Py_None)) {
  				/* Trace function raised an error */
! 				--tstate->recursion_depth;
! 				tstate->frame = f->f_back;
! 				return NULL;
  			}
  		}
--- 730,734 ----
  				       f, PyTrace_CALL, Py_None)) {
  				/* Trace function raised an error */
! 				goto exit_eval_frame;
  			}
  		}
***************
*** 723,729 ****
  				       f, PyTrace_CALL, Py_None)) {
  				/* Profile function raised an error */
! 				--tstate->recursion_depth;
! 				tstate->frame = f->f_back;
! 				return NULL;
  			}
  		}
--- 740,744 ----
  				       f, PyTrace_CALL, Py_None)) {
  				/* Profile function raised an error */
! 				goto exit_eval_frame;
  			}
  		}
***************
*** 2429,2433 ****
  
  	/* pop frame */
! 	--tstate->recursion_depth;
  	tstate->frame = f->f_back;
  
--- 2444,2449 ----
  
  	/* pop frame */
!     exit_eval_frame:
! 	Py_LeaveRecursiveCall();
  	tstate->frame = f->f_back;
  





More information about the Python-checkins mailing list