summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-18 15:13:31 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-18 15:13:31 (GMT)
commit1c7ade5284e8c7e245b50b51918fa30e9a877b99 (patch)
tree84939a02b300ba58fef02d42baf91afe948485c6
parent2fabface500d74457593b55ed06bc41ead88163e (diff)
downloadcpython-1c7ade5284e8c7e245b50b51918fa30e9a877b99.zip
cpython-1c7ade5284e8c7e245b50b51918fa30e9a877b99.tar.gz
cpython-1c7ade5284e8c7e245b50b51918fa30e9a877b99.tar.bz2
Fix leaking a RuntimeError objects when creating sub-interpreters
-rw-r--r--Objects/exceptions.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 0106ba3..fc41853 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -2093,27 +2093,29 @@ _PyExc_Init(void)
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);