This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Gwenlliana
Recipients Gwenlliana, anupama.srinivas.murthy, r.david.murray, rhettinger
Date 2015-01-18.20:22:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1421612535.62.0.896014519729.issue23217@psf.upfronthosting.co.za>
In-reply-to
Content
The capture actually worked correctly. It seems to be caused by the artifacts introduced by the evaluation function decorators.

Decorator lists for functions are compiled to a series of high-order function applications to the original function, followed by an assignment which stores the resulting function object to the name of the original function. A decompilation of the sample code might be something like this:

  3           0 LOAD_CONST               0 (<code object outer at ...>)
              3 MAKE_FUNCTION            0
              6 STORE_NAME               0 (outer)

 10           9 LOAD_NAME                0 (outer)
             12 LOAD_CONST               1 (<code object f ...>)
             15 MAKE_FUNCTION            0
             18 CALL_FUNCTION            1
             21 STORE_NAME               1 (f)
             24 LOAD_CONST               2 (None)
             27 RETURN_VALUE        

It works in the same way with `f = outer(lambda: None)`. Thus evaluating `f.__name__` or `f.func_name` would actually gives the __name__ property of that inner function object, thus `help(f)` actually queries the help information of function inner.

Similarly, lots of properties of the original function object f would be shadowed by the decoration process, including the __doc__ property. You'll find documenting f takes no effect on the value of `f.__doc__`:

    @outer
    def f():
    """ The docstring of function f """
        return

>>> help(f)
Help on function inner in module tmp:

inner()
    #comment
History
Date User Action Args
2015-01-18 20:22:15Gwenllianasetrecipients: + Gwenlliana, rhettinger, r.david.murray, anupama.srinivas.murthy
2015-01-18 20:22:15Gwenllianasetmessageid: <1421612535.62.0.896014519729.issue23217@psf.upfronthosting.co.za>
2015-01-18 20:22:15Gwenllianalinkissue23217 messages
2015-01-18 20:22:15Gwenllianacreate