summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-09-05 19:11:53 +0000
committerGuido van Rossum <guido@python.org>1997-09-05 19:11:53 +0000
commitfd26933ff04fe5ef57389f0ff25fb682c7a8d75a (patch)
tree385eb436c9a410b22097d7c77f0a68b115fb5b9b /Python/pythonrun.c
parent69bb5ed24b3bf57c8074f6e8ce340385afa0c900 (diff)
downloadcpython-fd26933ff04fe5ef57389f0ff25fb682c7a8d75a.tar.gz
Fixed some details of printing the str() of an exception. This fixes
a core dump when __str__() returns a non-string, and plugs a memory leak as well: the result of PyObject_Str() was never DECREFed.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index c7832dc384..610ec7a1f5 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -761,10 +761,14 @@ PyErr_Print()
/* only print colon if the str() of the
object is not the empty string
*/
- if (s && strcmp(PyString_AsString(s), ""))
+ 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(v, f, Py_PRINT_RAW);
+ err = PyFile_WriteObject(s, f, Py_PRINT_RAW);
+ Py_XDECREF(s);
}
}
if (err == 0)