summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/errors.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 48649fd..91c543d 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -256,7 +256,15 @@ PyErr_BadArgument()
PyObject *
PyErr_NoMemory()
{
- PyErr_SetNone(PyExc_MemoryError);
+ /* raise the pre-allocated instance if it still exists */
+ if (PyExc_MemoryErrorInst)
+ 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
+ */
+ PyErr_SetNone(PyExc_MemoryError);
+
return NULL;
}