Kaydet (Commit) 1c7ade52 authored tarafından Antoine Pitrou's avatar Antoine Pitrou

Fix leaking a RuntimeError objects when creating sub-interpreters

üst 2fabface
...@@ -2093,27 +2093,29 @@ _PyExc_Init(void) ...@@ -2093,27 +2093,29 @@ _PyExc_Init(void)
preallocate_memerrors(); preallocate_memerrors();
PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL); if (!PyExc_RecursionErrorInst) {
if (!PyExc_RecursionErrorInst) PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
Py_FatalError("Cannot pre-allocate RuntimeError instance for " if (!PyExc_RecursionErrorInst)
"recursion errors"); Py_FatalError("Cannot pre-allocate RuntimeError instance for "
else { "recursion errors");
PyBaseExceptionObject *err_inst = else {
(PyBaseExceptionObject *)PyExc_RecursionErrorInst; PyBaseExceptionObject *err_inst =
PyObject *args_tuple; (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
PyObject *exc_message; PyObject *args_tuple;
exc_message = PyUnicode_FromString("maximum recursion depth exceeded"); PyObject *exc_message;
if (!exc_message) exc_message = PyUnicode_FromString("maximum recursion depth exceeded");
Py_FatalError("cannot allocate argument for RuntimeError " if (!exc_message)
"pre-allocation"); Py_FatalError("cannot allocate argument for RuntimeError "
args_tuple = PyTuple_Pack(1, exc_message); "pre-allocation");
if (!args_tuple) args_tuple = PyTuple_Pack(1, exc_message);
Py_FatalError("cannot allocate tuple for RuntimeError " if (!args_tuple)
"pre-allocation"); Py_FatalError("cannot allocate tuple for RuntimeError "
Py_DECREF(exc_message); "pre-allocation");
if (BaseException_init(err_inst, args_tuple, NULL)) Py_DECREF(exc_message);
Py_FatalError("init of pre-allocated RuntimeError failed"); if (BaseException_init(err_inst, args_tuple, NULL))
Py_DECREF(args_tuple); Py_FatalError("init of pre-allocated RuntimeError failed");
Py_DECREF(args_tuple);
}
} }
Py_DECREF(bltinmod); Py_DECREF(bltinmod);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment