From f54a574478e955d3175f9be5ac3a6c4533e68763 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 22 Jul 2013 22:28:37 +0200 Subject: Issue #18520: PyErr_NoMemory() now fails with a fatal error if it is called before PyExc_MemoryError has been initialized by _PyExc_Init() --- Python/errors.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Python/errors.c') diff --git a/Python/errors.c b/Python/errors.c index b0f8b189392..8c0c01849c3 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -380,6 +380,12 @@ PyErr_BadArgument(void) PyObject * PyErr_NoMemory(void) { + if (Py_TYPE(PyExc_MemoryError) == NULL) { + /* PyErr_NoMemory() has been called before PyExc_MemoryError has been + initialized by _PyExc_Init() */ + Py_FatalError("Out of memory and PyExc_MemoryError is not " + "initialized yet"); + } PyErr_SetNone(PyExc_MemoryError); return NULL; } -- cgit v1.2.3