>>> g.throw(ValueError, TypeError(1)) # mismatched type, rewrapped
caught ValueError (1)
+>>> g.throw(ValueError, ValueError(1), None) # explicit None traceback
+caught ValueError (1)
+
>>> g.throw(ValueError(1), "foo") # bad args
Traceback (most recent call last):
...
>>> f().throw("abc") # throw on just-opened generator
Traceback (most recent call last):
...
-TypeError: exceptions must be classes, or instances, not str
-
+abc
Now let's try closing a generator:
Py_INCREF(typ);
}
}
- else {
+
+ /* Allow raising builtin string exceptions */
+
+ else if (!PyString_CheckExact(typ)) {
/* Not something you can raise. throw() fails. */
PyErr_Format(PyExc_TypeError,
"exceptions must be classes, or instances, not %s",