-
-
Notifications
You must be signed in to change notification settings - Fork 189
Closed
Labels
Milestone
Description
In the code below, the results for fun_2 are incomplete:
class Decorator(object):
def __init__(self, item):
self.item = item
self.func = None
def __call__(self, func):
self.func = func
return self
@Decorator(42)
def fun_1():
pass
@Decorator(lambda x: 42)
def fun_2():
pass
@Decorator(fun_2.item)
def fun_3():
pass
import inspect
print("Inspect results")
print(inspect.getsource(fun_1.func))
print(inspect.getsource(fun_2.func))
print(inspect.getsource(fun_3.func))
import dill
print("Dill results")
print(dill.source.getsource(fun_1.func))
print(dill.source.getsource(fun_2.func))
print(dill.source.getsource(fun_3.func))
The expected results are:
@Decorator(lambda x: 42)
def fun_2():
pass
but what is obtained is
@Decorator(lambda x: 42)
Both dill and inspect fail with the same results.
Note this issue was reported on StackOverflow: http://stackoverflow.com/questions/43063658
Reactions are currently unavailable