[Python-checkins] cpython (3.2): Fix leaking a RuntimeError objects when creating sub-interpreters

antoine.pitrou python-checkins at python.org
Wed Jan 18 16:23:04 CET 2012


http://hg.python.org/cpython/rev/ab5b47bf6711
changeset:   74498:ab5b47bf6711
branch:      3.2
parent:      74496:93e86b9318f7
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed Jan 18 16:13:31 2012 +0100
summary:
  Fix leaking a RuntimeError objects when creating sub-interpreters

files:
  Objects/exceptions.c |  44 ++++++++++++++++---------------
  1 files changed, 23 insertions(+), 21 deletions(-)


diff --git a/Objects/exceptions.c b/Objects/exceptions.c
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -2093,27 +2093,29 @@
 
     preallocate_memerrors();
 
-    PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
-    if (!PyExc_RecursionErrorInst)
-        Py_FatalError("Cannot pre-allocate RuntimeError instance for "
-                        "recursion errors");
-    else {
-        PyBaseExceptionObject *err_inst =
-            (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
-        PyObject *args_tuple;
-        PyObject *exc_message;
-        exc_message = PyUnicode_FromString("maximum recursion depth exceeded");
-        if (!exc_message)
-            Py_FatalError("cannot allocate argument for RuntimeError "
-                            "pre-allocation");
-        args_tuple = PyTuple_Pack(1, exc_message);
-        if (!args_tuple)
-            Py_FatalError("cannot allocate tuple for RuntimeError "
-                            "pre-allocation");
-        Py_DECREF(exc_message);
-        if (BaseException_init(err_inst, args_tuple, NULL))
-            Py_FatalError("init of pre-allocated RuntimeError failed");
-        Py_DECREF(args_tuple);
+    if (!PyExc_RecursionErrorInst) {
+        PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
+        if (!PyExc_RecursionErrorInst)
+            Py_FatalError("Cannot pre-allocate RuntimeError instance for "
+                            "recursion errors");
+        else {
+            PyBaseExceptionObject *err_inst =
+                (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
+            PyObject *args_tuple;
+            PyObject *exc_message;
+            exc_message = PyUnicode_FromString("maximum recursion depth exceeded");
+            if (!exc_message)
+                Py_FatalError("cannot allocate argument for RuntimeError "
+                                "pre-allocation");
+            args_tuple = PyTuple_Pack(1, exc_message);
+            if (!args_tuple)
+                Py_FatalError("cannot allocate tuple for RuntimeError "
+                                "pre-allocation");
+            Py_DECREF(exc_message);
+            if (BaseException_init(err_inst, args_tuple, NULL))
+                Py_FatalError("init of pre-allocated RuntimeError failed");
+            Py_DECREF(args_tuple);
+        }
     }
 
     Py_DECREF(bltinmod);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list