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

brett.cannon python-checkins at python.org
Tue Feb 28 00:39:11 CET 2006


Author: brett.cannon
Date: Tue Feb 28 00:39:10 2006
New Revision: 42632

Modified:
   python/trunk/Misc/NEWS
   python/trunk/Python/ceval.c
Log:
Check the return code for PyErr_Warn() when warning about raising string
exceptions.  This was triggered when 'warnings' had a filter set to "error"
that caught the string exception deprecation warning.


Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue Feb 28 00:39:10 2006
@@ -12,6 +12,10 @@
 Core and builtins
 -----------------
 
+- Properly check if 'warnings' raises an exception (usually when a filter set
+  to "error" is triggered) when raising a warning for raising string
+  exceptions.
+
 - CO_GENERATOR_ALLOWED is no longer defined, this behavior is the default.
   The name was removed from Include/code.h.
 

Modified: python/trunk/Python/ceval.c
==============================================================================
--- python/trunk/Python/ceval.c	(original)
+++ python/trunk/Python/ceval.c	Tue Feb 28 00:39:10 2006
@@ -2997,13 +2997,14 @@
 		Py_DECREF(tmp);
 	}
 
-	if (PyString_CheckExact(type))
+	if (PyString_CheckExact(type)) {
 		/* Raising builtin string is deprecated but still allowed --
 		 * do nothing.  Raising an instance of a new-style str
 		 * subclass is right out. */
-		PyErr_Warn(PyExc_PendingDeprecationWarning,
-			   "raising a string exception is deprecated");
-
+		if (-1 == PyErr_Warn(PyExc_PendingDeprecationWarning,
+			   "raising a string exception is deprecated"))
+			goto raise_error;
+	}
 	else if (PyClass_Check(type))
 		PyErr_NormalizeException(&type, &value, &tb);
 


More information about the Python-checkins mailing list