[Twisted-Python] A kinder and more consistent defer.inlineCallbacks

Terry Jones terry at jon.es
Fri Nov 28 07:00:37 MST 2008


Hi JP

> 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)
>   >>> 

Ah... thanks.

> 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´.

Right, not without looking at the text of the exception, which, apart from
being extremely would be unreliable. Too bad there's not a Python exception
for incorrect function/method arg passing.

> See also <http://twistedmatrix.com/trac/ticket/2501>.

Ha!  There's pretty much the whole of this thread in there. I'll look more
carefully in trac next time. I did look at some point, and saw another
issue discussing what to do if a non-deferred is yielded.

Thanks again.

Terry




More information about the Twisted-Python mailing list