summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-22 20:28:37 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-22 20:28:37 (GMT)
commitf54a574478e955d3175f9be5ac3a6c4533e68763 (patch)
treeb54ebef0f3750abfd0e0be7b0d85374050f5e10f /Python/errors.c
parent1c8f059019d79f1891f42a2656a96919a1187967 (diff)
downloadcpython-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.c6
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;
}