[Python-checkins] r61486 - in python/trunk: Misc/NEWS Python/ceval.c

guido.van.rossum python-checkins at python.org
Tue Mar 18 05:26:49 CET 2008


Author: guido.van.rossum
Date: Tue Mar 18 05:26:48 2008
New Revision: 61486

Modified:
   python/trunk/Misc/NEWS
   python/trunk/Python/ceval.c
Log:
Issue #2341: Add a Py3k warning when raising an exception that doesn't
derive from BaseException.


Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue Mar 18 05:26:48 2008
@@ -13,7 +13,8 @@
 -----------------
 
 - Issue #2371: Add a Py3k warning when catching an exception that
-  doesn't derive from BaseException.
+  doesn't derive from BaseException.  Issue #2341: Add a Py3k warning
+  when raising an exception that doesn't derive from BaseException.
 
 - Issue #2321: use pymalloc for unicode object string data to reduce
   memory usage in some circumstances.

Modified: python/trunk/Python/ceval.c
==============================================================================
--- python/trunk/Python/ceval.c	(original)
+++ python/trunk/Python/ceval.c	Tue Mar 18 05:26:48 2008
@@ -3161,6 +3161,15 @@
 			     type->ob_type->tp_name);
 		goto raise_error;
 	}
+
+	assert(PyExceptionClass_Check(type));
+	if (Py_Py3kWarningFlag && PyClass_Check(type)) {
+		if (PyErr_Warn(PyExc_DeprecationWarning,
+			       "exceptions must derive from BaseException "
+			       "in 3.x") == -1)
+			goto raise_error;
+	}
+
 	PyErr_Restore(type, value, tb);
 	if (tb == NULL)
 		return WHY_EXCEPTION;


More information about the Python-checkins mailing list