diff Python/errors.c @ 6190:b5757e87eb32 legacy-trunk

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).
author Barry Warsaw <barry@python.org>
date Fri, 29 Aug 1997 21:54:35 +0000
parents a2a1df0ca808
children b7f0b98f5325
line wrap: on
line diff
--- a/Python/errors.c	Fri Aug 29 21:52:14 1997 +0000
+++ b/Python/errors.c	Fri Aug 29 21:54:35 1997 +0000
@@ -256,7 +256,15 @@
 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;
 }