summaryrefslogtreecommitdiff
path: root/Python/errors.c
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1997-08-29 21:54:35 +0000
committerBarry Warsaw <barry@python.org>1997-08-29 21:54:35 +0000
commit4e29f3751ce804bc47ce18fa54b1c20674619d36 (patch)
treecab3cb1296a77ba567aac011b443dc92a9ddb3da /Python/errors.c
parent2cbae4175aecacfbed3cae319d51cc799ceaa13d (diff)
downloadcpython-4e29f3751ce804bc47ce18fa54b1c20674619d36.tar.gz
PyErr_NoMemory(): If the pre-instantiated memory exception is non-null
(PyExc_MemoryErrorInst) raise this instead of PyExc_MemoryError. This only happens when exception classes are enabled (e.g. when Python is started with -X).
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 48649fda3c..91c543d0fa 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;
}