]> granicus.if.org Git - python/commitdiff
Check the return code for PyErr_Warn() when warning about raising string
authorBrett Cannon <bcannon@gmail.com>
Mon, 27 Feb 2006 23:39:10 +0000 (23:39 +0000)
committerBrett Cannon <bcannon@gmail.com>
Mon, 27 Feb 2006 23:39:10 +0000 (23:39 +0000)
exceptions.  This was triggered when 'warnings' had a filter set to "error"
that caught the string exception deprecation warning.

Misc/NEWS
Python/ceval.c

index 4e16038deb72922cf7eaa5282c33207d7511b8c3..3ad50b5df486da9bb9000e855687cdd89db691a4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@ What's New in Python 2.5 alpha 1?
 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.
 
index e2f38acc47baba1283f8e2eaef74186fa629dc4d..2c2104e034a8f4848fccb5e55beb90c73fb6291e 100644 (file)
@@ -2997,13 +2997,14 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
                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);