diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-22 20:28:37 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-22 20:28:37 (GMT) |
commit | f54a574478e955d3175f9be5ac3a6c4533e68763 (patch) | |
tree | b54ebef0f3750abfd0e0be7b0d85374050f5e10f /Python/errors.c | |
parent | 1c8f059019d79f1891f42a2656a96919a1187967 (diff) | |
download | cpython-f54a574478e955d3175f9be5ac3a6c4533e68763.zip cpython-f54a574478e955d3175f9be5ac3a6c4533e68763.tar.gz cpython-f54a574478e955d3175f9be5ac3a6c4533e68763.tar.bz2 |
Issue #18520: PyErr_NoMemory() now fails with a fatal error if it is called
before PyExc_MemoryError has been initialized by _PyExc_Init()
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c index b0f8b18..8c0c018 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; } |