Commit 5e9d6cfb authored by Tim Peters's avatar Tim Peters

PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste

bug in both:  `className` was referenced before being checked for NULL.
parent a37722cc
......@@ -588,13 +588,16 @@ PyErr_WriteUnraisable(PyObject *obj)
if (f != NULL) {
PyFile_WriteString("Exception ", f);
if (t) {
char* className = PyExceptionClass_Name(t);
PyObject* moduleName;
char* className = PyExceptionClass_Name(t);
if (className != NULL) {
char *dot = strrchr(className, '.');
if (dot != NULL)
className = dot+1;
moduleName = PyObject_GetAttrString(t, "__module__");
}
moduleName = PyObject_GetAttrString(t, "__module__");
if (moduleName == NULL)
PyFile_WriteString("<unknown>", f);
else {
......
......@@ -1132,13 +1132,15 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
/* Don't do anything else */
}
else if (PyExceptionClass_Check(exception)) {
PyObject* moduleName;
char* className = PyExceptionClass_Name(exception);
if (className != NULL) {
char *dot = strrchr(className, '.');
PyObject* moduleName;
if (dot != NULL)
className = dot+1;
moduleName = PyObject_GetAttrString(exception, "__module__");
}
moduleName = PyObject_GetAttrString(exception, "__module__");
if (moduleName == NULL)
err = PyFile_WriteString("<unknown>", f);
else {
......
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