[Python-checkins] CVS: python/dist/src/Python ceval.c,2.277,2.278

Jeremy Hylton jhylton@users.sourceforge.net
Wed, 26 Sep 2001 12:24:47 -0700


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

Modified Files:
	ceval.c 
Log Message:
Prevent a NULL pointer from being pushed onto the stack.

It's possible for PyErr_NormalizeException() to set the traceback
pointer to NULL.  I'm not sure how to provoke this directly from
Python, although it may be possible.  The error occurs when an
exception is set using PyErr_SetObject() and another exception occurs
while PyErr_NormalizeException() is creating the exception instance.

XXX As a result of this change, it's possible for an exception to
occur but sys.last_traceback to be left undefined.  Not sure if this
is a problem.


Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.277
retrieving revision 2.278
diff -C2 -d -r2.277 -r2.278
*** ceval.c	2001/09/24 19:32:01	2.277
--- ceval.c	2001/09/26 19:24:45	2.278
***************
*** 2256,2260 ****
  							     exc, val, tb);
  					}
! 					PUSH(tb);
  					PUSH(val);
  					PUSH(exc);
--- 2256,2264 ----
  							     exc, val, tb);
  					}
! 					if (tb == NULL) {
! 						Py_INCREF(Py_None);
! 						PUSH(Py_None);
! 					} else
! 						PUSH(tb);
  					PUSH(val);
  					PUSH(exc);