From bf36409e2a8171b441d5e0a2f1c9e02d31a35ae8 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 1 Mar 2006 04:25:17 +0000 Subject: 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. --- Python/ceval.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Python/ceval.c') diff --git a/Python/ceval.c b/Python/ceval.c index 3ef853ea1b..8d0f7e6ce2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1685,7 +1685,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throw) why == WHY_CONTINUE) retval = POP(); } - else if (PyClass_Check(v) || PyString_Check(v)) { + else if (PyExceptionClass_Check(v) || PyString_Check(v)) { w = POP(); u = POP(); PyErr_Restore(v, w, u); @@ -3026,14 +3026,14 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb) /* Raising builtin string is deprecated but still allowed -- * do nothing. Raising an instance of a new-style str * subclass is right out. */ - if (-1 == PyErr_Warn(PyExc_PendingDeprecationWarning, + if (PyErr_Warn(PyExc_DeprecationWarning, "raising a string exception is deprecated")) goto raise_error; } - else if (PyClass_Check(type)) + else if (PyExceptionClass_Check(type)) PyErr_NormalizeException(&type, &value, &tb); - else if (PyInstance_Check(type)) { + else if (PyExceptionInstance_Check(type)) { /* Raising an instance. The value should be a dummy. */ if (value != Py_None) { PyErr_SetString(PyExc_TypeError, @@ -3044,7 +3044,7 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb) /* Normalize to raise , */ Py_DECREF(value); value = type; - type = (PyObject*) ((PyInstanceObject*)type)->in_class; + type = PyExceptionInstance_Class(type); Py_INCREF(type); } } -- cgit v1.2.1