From 4f453e0cde3ce1ec854b22eab7b46e2c38fcdd1f Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Mon, 17 May 2021 22:50:52 +0100 Subject: [PATCH] Tidy up handling of OOM exceptions - Py*_New will call PyErr_NoMemory() internally, so there is no need to call it again here, just correctly handle the NULL return value --- Lib/python/pyrun.swg | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index f32afb07e..83060484f 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -296,7 +296,6 @@ SwigPyClientData_New(PyObject* obj) Py_DECREF(data->newraw); Py_DECREF(data->klass); free(data); - PyErr_NoMemory(); return 0; } } else { @@ -355,10 +354,7 @@ SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) if (!sobj->dict) sobj->dict = PyDict_New(); - if (!sobj->dict) - return PyErr_NoMemory(); - - Py_INCREF(sobj->dict); + Py_XINCREF(sobj->dict); return sobj->dict; }