Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 38431:4c0823f0a0a1 legacy-trunk
Conversion of exceptions over from faked-up classes to new-style C types.
| author | Richard Jones <richard@commonground.com.au> |
|---|---|
| date | Sat, 27 May 2006 12:29:24 +0000 |
| parents | 35f27bbd9ad8 |
| children | 1a23706139ca |
comparison
equal
deleted
inserted
replaced
| 38430:795d1cb1df01 | 38431:4c0823f0a0a1 |
|---|---|
| 1082 Py_XDECREF(exception); | 1082 Py_XDECREF(exception); |
| 1083 Py_XDECREF(v); | 1083 Py_XDECREF(v); |
| 1084 Py_XDECREF(tb); | 1084 Py_XDECREF(tb); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) | 1087 void |
| 1088 PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) | |
| 1088 { | 1089 { |
| 1089 int err = 0; | 1090 int err = 0; |
| 1090 PyObject *f = PySys_GetObject("stderr"); | 1091 PyObject *f = PySys_GetObject("stderr"); |
| 1091 Py_INCREF(value); | 1092 Py_INCREF(value); |
| 1092 if (f == NULL) | 1093 if (f == NULL) |
| 1130 if (err) { | 1131 if (err) { |
| 1131 /* Don't do anything else */ | 1132 /* Don't do anything else */ |
| 1132 } | 1133 } |
| 1133 else if (PyExceptionClass_Check(exception)) { | 1134 else if (PyExceptionClass_Check(exception)) { |
| 1134 char* className = PyExceptionClass_Name(exception); | 1135 char* className = PyExceptionClass_Name(exception); |
| 1135 PyObject* moduleName = | 1136 char *dot = strrchr(className, '.'); |
| 1136 PyObject_GetAttrString(exception, "__module__"); | 1137 PyObject* moduleName; |
| 1138 if (dot != NULL) | |
| 1139 className = dot+1; | |
| 1140 moduleName = PyObject_GetAttrString(exception, "__module__"); | |
| 1137 | 1141 |
| 1138 if (moduleName == NULL) | 1142 if (moduleName == NULL) |
| 1139 err = PyFile_WriteString("<unknown>", f); | 1143 err = PyFile_WriteString("<unknown>", f); |
| 1140 else { | 1144 else { |
| 1141 char* modstr = PyString_AsString(moduleName); | 1145 char* modstr = PyString_AsString(moduleName); |
| 1142 Py_DECREF(moduleName); | |
| 1143 if (modstr && strcmp(modstr, "exceptions")) | 1146 if (modstr && strcmp(modstr, "exceptions")) |
| 1144 { | 1147 { |
| 1145 err = PyFile_WriteString(modstr, f); | 1148 err = PyFile_WriteString(modstr, f); |
| 1146 err += PyFile_WriteString(".", f); | 1149 err += PyFile_WriteString(".", f); |
| 1147 } | 1150 } |
| 1151 Py_DECREF(moduleName); | |
| 1148 } | 1152 } |
| 1149 if (err == 0) { | 1153 if (err == 0) { |
| 1150 if (className == NULL) | 1154 if (className == NULL) |
| 1151 err = PyFile_WriteString("<unknown>", f); | 1155 err = PyFile_WriteString("<unknown>", f); |
| 1152 else | 1156 else |
