diff Python/errors.c @ 48598:de75e7280b7a

Correct one of the "MemoryError oddities": the traceback would grow each time a MemoryError is raised.
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Thu, 31 Jul 2008 22:56:02 +0000
parents 1ec38b707cd6
children 85b67fb5672b
line wrap: on
line diff
--- a/Python/errors.c	Thu Jul 31 21:10:28 2008 +0000
+++ b/Python/errors.c	Thu Jul 31 22:56:02 2008 +0000
@@ -321,7 +321,17 @@
 
 	/* raise the pre-allocated instance if it still exists */
 	if (PyExc_MemoryErrorInst)
+	{
+		/* Clear the previous traceback, otherwise it will be appended
+		 * to the current one.
+		 *
+		 * The following statement is not likely to raise any error;
+		 * if it does, we simply discard it.
+		 */
+		PyException_SetTraceback(PyExc_MemoryErrorInst, Py_None);
+
 		PyErr_SetObject(PyExc_MemoryError, PyExc_MemoryErrorInst);
+	}
 	else
 		/* this will probably fail since there's no memory and hee,
 		   hee, we have to instantiate this class