]> granicus.if.org Git - python/commitdiff
PyErr_NoMemory(): If the pre-instantiated memory exception is non-null
authorBarry Warsaw <barry@python.org>
Fri, 29 Aug 1997 21:54:35 +0000 (21:54 +0000)
committerBarry Warsaw <barry@python.org>
Fri, 29 Aug 1997 21:54:35 +0000 (21:54 +0000)
(PyExc_MemoryErrorInst) raise this instead of PyExc_MemoryError.  This
only happens when exception classes are enabled (e.g. when Python is
started with -X).

Python/errors.c

index 48649fda3c7edd33ce5fd9a9759b937a04b2fe1a..91c543d0fa7582d4272c2e8139749d95a1531cc7 100644 (file)
@@ -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;
 }