diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-22 22:28:37 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-22 22:28:37 +0200 |
commit | 964a3316f3209cfab36719a2f544b74d2694e3dc (patch) | |
tree | 75d9eaba08dc7c24027cdf56997b07a76d663c3f /Python | |
parent | 92d3e3cf6bfe7320aea27780a6525e6075624935 (diff) | |
download | cpython-964a3316f3209cfab36719a2f544b74d2694e3dc.tar.gz |
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')
-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 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; } |