summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2006-03-01 04:25:17 (GMT)
committerBrett Cannon <bcannon@gmail.com>2006-03-01 04:25:17 (GMT)
commitbf36409e2a8171b441d5e0a2f1c9e02d31a35ae8 (patch)
tree7456cf3d197d6f0dc017b0f851878bcaf6024f6c /Python/pythonrun.c
parent762467475d944f67ac20bf23c6c5144a6e39feae (diff)
downloadcpython-bf36409e2a8171b441d5e0a2f1c9e02d31a35ae8.zip
cpython-bf36409e2a8171b441d5e0a2f1c9e02d31a35ae8.tar.gz
cpython-bf36409e2a8171b441d5e0a2f1c9e02d31a35ae8.tar.bz2
PEP 352 implementation. Creates a new base class, BaseException, which has an
added message attribute compared to the previous version of Exception. It is also a new-style class, making all exceptions now new-style. KeyboardInterrupt and SystemExit inherit from BaseException directly. String exceptions now raise DeprecationWarning. Applies patch 1104669, and closes bugs 1012952 and 518846.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index d5c86f2..bbe9352 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -976,7 +976,7 @@ handle_system_exit(void)
fflush(stdout);
if (value == NULL || value == Py_None)
goto done;
- if (PyInstance_Check(value)) {
+ if (PyExceptionInstance_Check(value)) {
/* The error code should be in the `code' attribute. */
PyObject *code = PyObject_GetAttrString(value, "code");
if (code) {
@@ -1106,11 +1106,10 @@ void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
if (err) {
/* Don't do anything else */
}
- else if (PyClass_Check(exception)) {
- PyClassObject* exc = (PyClassObject*)exception;
- PyObject* className = exc->cl_name;
+ else if (PyExceptionClass_Check(exception)) {
+ char* className = PyExceptionClass_Name(exception);
PyObject* moduleName =
- PyDict_GetItemString(exc->cl_dict, "__module__");
+ PyObject_GetAttrString(exception, "__module__");
if (moduleName == NULL)
err = PyFile_WriteString("<unknown>", f);
@@ -1126,8 +1125,7 @@ void PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
if (className == NULL)
err = PyFile_WriteString("<unknown>", f);
else
- err = PyFile_WriteObject(className, f,
- Py_PRINT_RAW);
+ err = PyFile_WriteString(className, f);
}
}
else