(original) (raw)
changeset: 84794:9b77b3ee6fb8 user: Victor Stinner victor.stinner@gmail.com date: Mon Jul 22 22:28:37 2013 +0200 files: Python/errors.c description: Issue #18520: PyErr_NoMemory() now fails with a fatal error if it is called before PyExc_MemoryError has been initialized by _PyExc_Init() diff -r fc718c177ee6 -r 9b77b3ee6fb8 Python/errors.c --- a/Python/errors.c Mon Jul 22 22:24:54 2013 +0200 +++ b/Python/errors.c Mon Jul 22 22:28:37 2013 +0200 @@ -380,6 +380,12 @@ 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; } /victor.stinner@gmail.com