summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorRichard Jones <richard@commonground.com.au>2006-05-27 12:29:24 (GMT)
committerRichard Jones <richard@commonground.com.au>2006-05-27 12:29:24 (GMT)
commit7b9558d37dc7f2c6ae984cf25d16b9bf5e532b77 (patch)
tree70f313905c1ef84f4ba281cab615c32e06820460 /Python/pythonrun.c
parent1fcdc232dbfbd05b92eaed42bf9f779d27c55a92 (diff)
downloadcpython-7b9558d37dc7f2c6ae984cf25d16b9bf5e532b77.zip
cpython-7b9558d37dc7f2c6ae984cf25d16b9bf5e532b77.tar.gz
cpython-7b9558d37dc7f2c6ae984cf25d16b9bf5e532b77.tar.bz2
Conversion of exceptions over from faked-up classes to new-style C types.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 1dc4f28..6f3ff6f 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1084,7 +1084,8 @@ PyErr_PrintEx(int set_sys_last_vars)
Py_XDECREF(tb);
}
-void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
+void
+PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
{
int err = 0;
PyObject *f = PySys_GetObject("stderr");
@@ -1132,19 +1133,22 @@ void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
}
else if (PyExceptionClass_Check(exception)) {
char* className = PyExceptionClass_Name(exception);
- PyObject* moduleName =
- PyObject_GetAttrString(exception, "__module__");
+ char *dot = strrchr(className, '.');
+ PyObject* moduleName;
+ if (dot != NULL)
+ className = dot+1;
+ moduleName = PyObject_GetAttrString(exception, "__module__");
if (moduleName == NULL)
err = PyFile_WriteString("<unknown>", f);
else {
char* modstr = PyString_AsString(moduleName);
- Py_DECREF(moduleName);
if (modstr && strcmp(modstr, "exceptions"))
{
err = PyFile_WriteString(modstr, f);
err += PyFile_WriteString(".", f);
}
+ Py_DECREF(moduleName);
}
if (err == 0) {
if (className == NULL)