Here's some example code:
from functools import partial
from operator import gt
from decorator import decorator
@decorator
def dec(func, *args, **kwargs):
return func(*args, **kwargs)
@dec
def foo(bar: partial(gt, 5)) -> lambda x: x:
pass
Here's the resulting traceback:
Traceback (most recent call last):
File "foo.py", line 10, in <module>
def foo(bar: partial(gt, 5)) -> lambda x: x:
File "<string>", line 2, in dec
File "/Users/kamil/.virtualenvs/covenant/lib/python3.2/site-packages/decorator.py", line 200, in decorator
evaldict, undecorated=func, __wrapped__=func)
File "/Users/kamil/.virtualenvs/covenant/lib/python3.2/site-packages/decorator.py", line 187, in create
evaldict, addsource, **attrs)
File "/Users/kamil/.virtualenvs/covenant/lib/python3.2/site-packages/decorator.py", line 154, in make
code = compile(src, '<string>', 'single')
File "<string>", line 1
def foo(bar: functools.partial(<built-in function gt>, 5)) -> <function <lambda> at 0x1005cf2f8):
The BIF case could possibly be solved by doing some parsing of the annotations
returned from getfullargspec but I'm not aware of any method of getting the
code to define the lambda again. Perhaps it would be best to just filter out
the annotations from the function signature, but still assign them to
__annotations__ attribute of the resulting function?
Original issue reported on code.google.com by kamil.ki...@gmail.com on 11 Mar 2012 at 1:08
Original issue reported on code.google.com by
kamil.ki...@gmail.com
on 11 Mar 2012 at 1:08