mirror of https://github.com/python/cpython
PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both: `className` was referenced before being checked for NULL.
This commit is contained in:
parent
a37722cc42
commit
5e9d6cfbda
|
@ -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 *dot = strrchr(className, '.');
|
||||
if (dot != NULL)
|
||||
className = dot+1;
|
||||
moduleName = PyObject_GetAttrString(t, "__module__");
|
||||
char* className = PyExceptionClass_Name(t);
|
||||
|
||||
if (className != NULL) {
|
||||
char *dot = strrchr(className, '.');
|
||||
if (dot != NULL)
|
||||
className = dot+1;
|
||||
}
|
||||
|
||||
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)) {
|
||||
char* className = PyExceptionClass_Name(exception);
|
||||
char *dot = strrchr(className, '.');
|
||||
PyObject* moduleName;
|
||||
if (dot != NULL)
|
||||
className = dot+1;
|
||||
moduleName = PyObject_GetAttrString(exception, "__module__");
|
||||
char* className = PyExceptionClass_Name(exception);
|
||||
if (className != NULL) {
|
||||
char *dot = strrchr(className, '.');
|
||||
if (dot != NULL)
|
||||
className = dot+1;
|
||||
}
|
||||
|
||||
moduleName = PyObject_GetAttrString(exception, "__module__");
|
||||
if (moduleName == NULL)
|
||||
err = PyFile_WriteString("<unknown>", f);
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue