Author ysj.ray
Recipients belopolsky, christian.heimes, gpolo, michele_s, pitrou, ysj.ray
Date 2010-07-19.13:40:56
SpamBayes Score 0.000352567
Marked as misclassified No
Message-id <>
I don't think this patch is correct, because we don't know if the closure[0] is the wrapped function, consider the following case:

def fun():
    abc = 1
    def fun2():

In this case, the __closure__ of fun2 is [cell(1), ], the patch doesn't work.

I think the behavior of inspect.getsource(arg) is no problem because it indeed gives the right source code of arg, no matter arg is a wrapper function or an original function. michele argues that the result is not meaningful, through in most case it seems reasonably because wrapper functions usually do litter valuable work, but it is not correct for all cases. What if a wrapper function does more valuable work than the wrapped function? In this case should getsouce() give the source code of wrapper function because it's more meaningful? The concept "wrapper" and "wrapped" should have no relation with its source code.

I suggest you assign a special named attribute of all wrapper functions to its wrapped function yourself, something like "wrapped_function", and then you can walk through the wrapper chain to find the real source you want for each wrapper function. Then the stdard library's update_wrapper() and getsource() can remain unchanged.
Date User Action Args
2010-07-19 13:40:59ysj.raysetrecipients: + ysj.ray, michele_s, belopolsky, pitrou, christian.heimes, gpolo
2010-07-19 13:40:59ysj.raysetmessageid: <>
2010-07-19 13:40:57ysj.raylinkissue1764286 messages
2010-07-19 13:40:56ysj.raycreate