From: Victor Stinner Date: Mon, 22 Jul 2013 20:28:37 +0000 (+0200) Subject: Issue #18520: PyErr_NoMemory() now fails with a fatal error if it is called X-Git-Tag: v3.4.0a1~103 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f54a574478e955d3175f9be5ac3a6c4533e68763;p=python Issue #18520: PyErr_NoMemory() now fails with a fatal error if it is called before PyExc_MemoryError has been initialized by _PyExc_Init() --- diff --git a/Python/errors.c b/Python/errors.c index b0f8b18939..8c0c01849c 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; }