• Kirill Smelkov's avatar
    golang: Adjust @func to wrap functions with standalone wrapper with recognizable name · 0c0f4b2a
    Kirill Smelkov authored
    Since 5146eb0b (Add support for defer & recover) we have func, which for
    
        @func
        def f():
            ...
    
    will turn f to be run with additional frame where defer can register calls.
    
    This works ok, but so far the worker of the wrapper was defined inside
    func itself - each time func was used, and also the worker had "no
    speaking" name _. The latter was making tracebacks a bit harder to read.
    
    -> Move the wrapper to be standalone function with _goframe name. This
    removes a bit of import-time overhead when @func is called, and makes
    tracebacks a bit more readable.
    
    But my original motivation here is to be able to detect double
    func(func(·)) calls and make it idempotent - see next patch for that.
    
    /reviewed-by @levin.zimmermann
    /reviewed-on nexedi/pygolang!31
    0c0f4b2a
golang_test_defer_excchain.txt-ipython 1.88 KB