Kaydet (Commit) 4c20bc40 authored tarafından Brett Cannon's avatar Brett Cannon

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.
üst 0b712025
...@@ -1622,7 +1622,7 @@ ValueError: 7 ...@@ -1622,7 +1622,7 @@ ValueError: 7
>>> f().throw("abc") # throw on just-opened generator >>> f().throw("abc") # throw on just-opened generator
Traceback (most recent call last): Traceback (most recent call last):
... ...
abc TypeError: exceptions must be classes, or instances, not str
Now let's try closing a generator: Now let's try closing a generator:
......
...@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1? ...@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
Core and builtins 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 - Issue #1096: Prevent a segfault from getting the repr of a very deeply nested
list by using the recursion counter. list by using the recursion counter.
......
...@@ -252,10 +252,7 @@ gen_throw(PyGenObject *gen, PyObject *args) ...@@ -252,10 +252,7 @@ gen_throw(PyGenObject *gen, PyObject *args)
Py_INCREF(typ); Py_INCREF(typ);
} }
} }
else {
/* Allow raising builtin string exceptions */
else if (!PyString_CheckExact(typ)) {
/* Not something you can raise. throw() fails. */ /* Not something you can raise. throw() fails. */
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"exceptions must be classes, or instances, not %s", "exceptions must be classes, or instances, not %s",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment