diff Python/ceval.c @ 20114:233f9606ba8e legacy-trunk

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.
author Jeremy Hylton <jeremy@alum.mit.edu>
date Wed, 26 Sep 2001 19:24:45 +0000
parents ef3034a60a3e
children c6b6189a8397
line wrap: on
line diff
--- a/Python/ceval.c	Wed Sep 26 18:46:36 2001 +0000
+++ b/Python/ceval.c	Wed Sep 26 19:24:45 2001 +0000
@@ -2255,7 +2255,11 @@
 						set_exc_info(tstate,
 							     exc, val, tb);
 					}
-					PUSH(tb);
+					if (tb == NULL) {
+						Py_INCREF(Py_None);
+						PUSH(Py_None);
+					} else
+						PUSH(tb);
 					PUSH(val);
 					PUSH(exc);
 				}