Am 25.01.2014 01:13, schrieb Guido van Rossum:
On Fri, Jan 24, 2014 at 2:37 PM, Tobias Oberstein
<[email protected]> wrote:
I have noticed that `inspect.getargspec` won't return useful information on
functions decorated with `@asyncio.coroutine`.
(Sidenote: same with Twisted's `@inlineCallbacks`)
I presume you are talking about Trollius? It works for Tulip:
Nope, Python 3.4.0b1 .. I get this:
@asyncio.coroutine
def foo1(a, b = 3):
yield from asyncio.sleep(1)
return a + b
@asyncio.coroutine
def foo2(a, b = 3):
return a + b
print(inspect.getargspec(foo1))
print(inspect.getargspec(foo2))
$ python3 test2.py
ArgSpec(args=['a', 'b'], varargs=None, keywords=None, defaults=(3,))
ArgSpec(args=[], varargs='args', keywords='kw', defaults=None)
==
But yes, it indeed does work if there is a yield in the function (hence
the function actually is a coroutine). But it does not work if there is
a decorator, but the function is plain. Strange. Is this expected behavior?
However, `inspect.signature` from
http://www.python.org/dev/peps/pep-0362/
_does_ work (means: returns the actual function signature).
Will this be made available on Python 2, or are there fundamental reasons
this won't work out?
If it requires modifications to the inspect module it won't be
backported (new feature time is over). If it can be accomplished by
;( I see.
tweaking Trollius' @coroutine implementation, it might be done, if
someone who would know how to do this cares enough. Peresonally I
don't know and I don't care. :-(