comparison 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
comparison
equal deleted inserted replaced
36806:7099f6e68183 36807:de4816d344ee
1113 1113
1114 if (moduleName == NULL) 1114 if (moduleName == NULL)
1115 err = PyFile_WriteString("<unknown>", f); 1115 err = PyFile_WriteString("<unknown>", f);
1116 else { 1116 else {
1117 char* modstr = PyString_AsString(moduleName); 1117 char* modstr = PyString_AsString(moduleName);
1118 Py_DECREF(moduleName);
1118 if (modstr && strcmp(modstr, "exceptions")) 1119 if (modstr && strcmp(modstr, "exceptions"))
1119 { 1120 {
1120 err = PyFile_WriteString(modstr, f); 1121 err = PyFile_WriteString(modstr, f);
1121 err += PyFile_WriteString(".", f); 1122 err += PyFile_WriteString(".", f);
1122 } 1123 }
1128 err = PyFile_WriteString(className, f); 1129 err = PyFile_WriteString(className, f);
1129 } 1130 }
1130 } 1131 }
1131 else 1132 else
1132 err = PyFile_WriteObject(exception, f, Py_PRINT_RAW); 1133 err = PyFile_WriteObject(exception, f, Py_PRINT_RAW);
1133 if (err == 0) { 1134 if (err == 0 && (value != Py_None)) {
1134 if (value != Py_None) { 1135 PyObject *s = PyObject_Str(value);
1135 PyObject *s = PyObject_Str(value); 1136 /* only print colon if the str() of the
1136 /* only print colon if the str() of the 1137 object is not the empty string
1137 object is not the empty string 1138 */
1138 */ 1139 if (s == NULL)
1139 if (s == NULL) 1140 err = -1;
1140 err = -1; 1141 else if (!PyString_Check(s) ||
1141 else if (!PyString_Check(s) || 1142 PyString_GET_SIZE(s) != 0)
1142 PyString_GET_SIZE(s) != 0) 1143 err = PyFile_WriteString(": ", f);
1143 err = PyFile_WriteString(": ", f); 1144 if (err == 0)
1144 if (err == 0) 1145 err = PyFile_WriteObject(s, f, Py_PRINT_RAW);
1145 err = PyFile_WriteObject(s, f, Py_PRINT_RAW); 1146 Py_XDECREF(s);
1146 Py_XDECREF(s);
1147 }
1148 } 1147 }
1149 if (err == 0) 1148 if (err == 0)
1150 err = PyFile_WriteString("\n", f); 1149 err = PyFile_WriteString("\n", f);
1151 } 1150 }
1152 Py_DECREF(value); 1151 Py_DECREF(value);