summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1997-08-29 21:54:35 (GMT)
committerBarry Warsaw <barry@python.org>1997-08-29 21:54:35 (GMT)
commit2d8adff10a92fb979795e339395711f782fe71f8 (patch)
tree6b6a8dbf1bda468cdae29175492a841b43ddf1f0
parentdd82bb9c14eee9a66b2172f11638d9f7dec8d8b8 (diff)
downloadcpython-2d8adff10a92fb979795e339395711f782fe71f8.zip
cpython-2d8adff10a92fb979795e339395711f782fe71f8.tar.gz
cpython-2d8adff10a92fb979795e339395711f782fe71f8.tar.bz2
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).
-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;
}