summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-09-11 21:02:28 +0000
committerBrett Cannon <bcannon@gmail.com>2007-09-11 21:02:28 +0000
commit4c20bc40d73a7f4a977475e4fa02f7c8a43d796a (patch)
treebda917217f80707f88ab8514b5c0e383fd677b40
parent0b7120258a4df671291e39d3eb95a71a9dc4c186 (diff)
downloadcpython-git-4c20bc40d73a7f4a977475e4fa02f7c8a43d796a.tar.gz
Generators had their throw() method allowing string exceptions. That's a
no-no. Fixes issue #1147. Need to fix 2.5 to raise a proper warning if a string exception is passed in.
-rw-r--r--Lib/test/test_generators.py2
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/genobject.c5
3 files changed, 5 insertions, 5 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 2b0d47d1b6..5d50187b2c 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -1622,7 +1622,7 @@ ValueError: 7
>>> f().throw("abc") # throw on just-opened generator
Traceback (most recent call last):
...
-abc
+TypeError: exceptions must be classes, or instances, not str
Now let's try closing a generator:
diff --git a/Misc/NEWS b/Misc/NEWS
index 10f2c71e7c..e5e365a3d9 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
Core and builtins
-----------------
+- Issue #1147: Exceptions were directly allowing string exceptions in their
+ throw() method even though string exceptions no longer allowed.
+
- Issue #1096: Prevent a segfault from getting the repr of a very deeply nested
list by using the recursion counter.
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 14cc46b846..551d9fddc2 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -252,10 +252,7 @@ gen_throw(PyGenObject *gen, PyObject *args)
Py_INCREF(typ);
}
}
-
- /* Allow raising builtin string exceptions */
-
- else if (!PyString_CheckExact(typ)) {
+ else {
/* Not something you can raise. throw() fails. */
PyErr_Format(PyExc_TypeError,
"exceptions must be classes, or instances, not %s",