]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Cause passing a string to generator.throw() to raise a deprecation warning.
authorBrett Cannon <bcannon@gmail.com>
Tue, 11 Sep 2007 21:12:14 +0000 (21:12 +0000)
committerBrett Cannon <bcannon@gmail.com>
Tue, 11 Sep 2007 21:12:14 +0000 (21:12 +0000)
Misc/NEWS
Objects/genobject.c

index 214611bd04ea49582884f819549f0370fc0b7f6d..24b29eb0a9084abc591150dfb09cc7e16121162e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5.2c1?
 Core and builtins
 -----------------
 
+- Issue #1147: Generators were not raising a DeprecationWarning when a string
+  was passed into throw().
+
 - Patch #1031213: Decode source line in SyntaxErrors back to its original source
   encoding.
 
index 4d0c4f6ee8436fd999488bc973e89c3e0310372b..063b9075dd7eb05ededd6936d6d2464103793629 100644 (file)
@@ -262,6 +262,12 @@ gen_throw(PyGenObject *gen, PyObject *args)
                             typ->ob_type->tp_name);
                        goto failed_throw;
        }
+       else {
+               /* String exceptions are deprecated. */
+               if (PyErr_Warn(PyExc_DeprecationWarning,
+                                       "raising string exceptions is deprecated"))
+                       goto failed_throw;
+       }
 
        PyErr_Restore(typ, val, tb);
        return gen_send_ex(gen, Py_None, 1);