diff Python/ceval.c @ 36751:8e04de2480e4 legacy-trunk

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.
author Brett Cannon <bcannon@gmail.com>
date Wed, 01 Mar 2006 04:25:17 +0000
parents fa92fe15251a
children d0ca6302dd3c
line wrap: on
line diff
--- a/Python/ceval.c	Wed Mar 01 04:06:10 2006 +0000
+++ b/Python/ceval.c	Wed Mar 01 04:25:17 2006 +0000
@@ -1685,7 +1685,7 @@
 				    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 @@
 		/* 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 @@
 			/* Normalize to raise <class>, <instance> */
 			Py_DECREF(value);
 			value = type;
-			type = (PyObject*) ((PyInstanceObject*)type)->in_class;
+			type = PyExceptionInstance_Class(type);
 			Py_INCREF(type);
 		}
 	}