• Kirill Smelkov's avatar
    golang: Make @func to be idempotent · 5302558e
    Kirill Smelkov authored
    i.e. make double call of func(func(f)) to return exactly the same as func(f).
    
    This is correct to do as the first func call already returns a wrapper
    that setups additional frame for defer. The second func call, if doing
    the same, will wrap the thing just one more time and there will be two
    frames for defer, but defer needs only one to work correctly.
    
    So far we had no case when such double func calls would appear in
    practice, because
    
        @func
        @func
        def f():
             ...
    
    would immediately catch attention.
    
    However in the next patch we will have this case to appear internally
    when handling properties. So it is better to make sure beforehand no
    waste of resources will happen.
    
    /reviewed-by @levin.zimmermann
    /reviewed-on nexedi/pygolang!31
    5302558e
golang_test.py 54.4 KB