Issue #18520: PyErr_NoMemory() now fails with a fatal error if it is called

before PyExc_MemoryError has been initialized by _PyExc_Init()
This commit is contained in:
Victor Stinner 2013-07-22 22:28:37 +02:00
parent 1c8f059019
commit f54a574478
1 changed files with 6 additions and 0 deletions

View File

@ -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;
}