Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 36807:de4816d344ee legacy-trunk
Fix refleak in PyErr_Display().
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Thu, 02 Mar 2006 18:34:57 +0000 |
| parents | d6c30ce3868b |
| children | 9109b1a0d265 |
line wrap: on
line diff
--- a/Python/pythonrun.c Thu Mar 02 17:58:27 2006 +0000 +++ b/Python/pythonrun.c Thu Mar 02 18:34:57 2006 +0000 @@ -1115,6 +1115,7 @@ err = PyFile_WriteString("<unknown>", f); else { char* modstr = PyString_AsString(moduleName); + Py_DECREF(moduleName); if (modstr && strcmp(modstr, "exceptions")) { err = PyFile_WriteString(modstr, f); @@ -1130,21 +1131,19 @@ } else err = PyFile_WriteObject(exception, f, Py_PRINT_RAW); - if (err == 0) { - if (value != Py_None) { - PyObject *s = PyObject_Str(value); - /* only print colon if the str() of the - object is not the empty string - */ - if (s == NULL) - err = -1; - else if (!PyString_Check(s) || - PyString_GET_SIZE(s) != 0) - err = PyFile_WriteString(": ", f); - if (err == 0) - err = PyFile_WriteObject(s, f, Py_PRINT_RAW); - Py_XDECREF(s); - } + if (err == 0 && (value != Py_None)) { + PyObject *s = PyObject_Str(value); + /* only print colon if the str() of the + object is not the empty string + */ + if (s == NULL) + err = -1; + else if (!PyString_Check(s) || + PyString_GET_SIZE(s) != 0) + err = PyFile_WriteString(": ", f); + if (err == 0) + err = PyFile_WriteObject(s, f, Py_PRINT_RAW); + Py_XDECREF(s); } if (err == 0) err = PyFile_WriteString("\n", f);
