From e19cadb427b6910930b50584bd9066ab5b198300 Mon Sep 17 00:00:00 2001 From: Amaury Forgeot d'Arc Date: Thu, 31 Jul 2008 22:56:02 +0000 Subject: Correct one of the "MemoryError oddities": the traceback would grow each time a MemoryError is raised. --- Python/errors.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Python/errors.c') diff --git a/Python/errors.c b/Python/errors.c index a06ec02d9a..5ee6255a2a 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -321,7 +321,17 @@ PyErr_NoMemory(void) /* 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 -- cgit v1.2.1