summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2006-03-02 18:34:57 (GMT)
committerBrett Cannon <bcannon@gmail.com>2006-03-02 18:34:57 (GMT)
commit2e63b73a2cd0d7d560c762a4ae4ed5b2fd5eb7ea (patch)
treecd16f5261748c4772f699bea0b750d9a6e2a07ab /Python
parent857b300b2e1c2b27af84d6090ed4810df00f1b16 (diff)
downloadcpython-2e63b73a2cd0d7d560c762a4ae4ed5b2fd5eb7ea.zip
cpython-2e63b73a2cd0d7d560c762a4ae4ed5b2fd5eb7ea.tar.gz
cpython-2e63b73a2cd0d7d560c762a4ae4ed5b2fd5eb7ea.tar.bz2
Fix refleak in PyErr_Display().
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index a98c85a..1b2b829 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1115,6 +1115,7 @@ void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
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 @@ void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
}
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);