Kaydet (Commit) f54a5744 authored tarafından Victor Stinner's avatar Victor Stinner

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

before PyExc_MemoryError has been initialized by _PyExc_Init()
üst 1c8f0590
...@@ -380,6 +380,12 @@ PyErr_BadArgument(void) ...@@ -380,6 +380,12 @@ PyErr_BadArgument(void)
PyObject * PyObject *
PyErr_NoMemory(void) 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); PyErr_SetNone(PyExc_MemoryError);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment