mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Exception__str__(): In case 1, be sure to decref the tmp local
variable. This crushes another memory leak. Slight rewrite included.
This commit is contained in:
parent
a1ae88432d
commit
b78165566e
1 changed files with 8 additions and 4 deletions
|
@ -231,7 +231,6 @@ static PyObject*
|
||||||
Exception__str__(PyObject* self, PyObject* args)
|
Exception__str__(PyObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
PyObject* out;
|
PyObject* out;
|
||||||
PyObject* tmp;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &self))
|
if (!PyArg_ParseTuple(args, "O", &self))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -245,11 +244,16 @@ Exception__str__(PyObject* self, PyObject* args)
|
||||||
out = PyString_FromString("");
|
out = PyString_FromString("");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (!(tmp = PySequence_GetItem(args, 0)))
|
{
|
||||||
out = NULL;
|
PyObject* tmp = PySequence_GetItem(args, 0);
|
||||||
else
|
if (tmp) {
|
||||||
out = PyObject_Str(tmp);
|
out = PyObject_Str(tmp);
|
||||||
|
Py_DECREF(tmp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
out = NULL;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
out = PyObject_Str(args);
|
out = PyObject_Str(args);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue