[Twisted-Python] A kinder and more consistent defer.inlineCallbacks
Jean-Paul Calderone
exarkun at divmod.com
Mon Nov 24 13:07:17 EST 2008
On Sun, 23 Nov 2008 04:58:54 +0100, Terry Jones <terry at jon.es> wrote:
> [snip]
>
>That's what I was addressing in the code above. If you call the function in
>unwindGenerator and you get an exception, you 1) know it's not a generator
>(that's what I didn't understand earlier - calling a function with a yield
>in it can never give you an exception, Python builds you a generator and
>gives you that)
Not quite:
>>> def f():
... yield None
...
>>> f(1, 2, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() takes no arguments (3 given)
>>>
And unfortunately, there is essentially no way to differentiate this case
from a case where the call to `f´ succeeded but some code executed as a
result of that raised a `TypeError´.
See also <http://twistedmatrix.com/trac/ticket/2501>.
Jean-Paul
More information about the Twisted-Python
mailing list