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 ballingt
Recipients ballingt
Date 2014-04-14.17:31:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1397496660.33.0.566497694968.issue21217@psf.upfronthosting.co.za>
In-reply-to
Content
https://gist.github.com/thomasballinger/10666031

"""
inspect.getsourcelines incorrectly guesses what lines correspond
to the function foo
 
see getblock in inspect.py
once it finds a lambda, def or class it finishes it then stops
so get getsourcelines returns only the first two noop decorator
lines of bar, while normal behavior is to return all decorators
as it does for foo
"""
import inspect
from pprint import pprint
 
def noop(arg):
    def inner(func):
        return func
    return inner
 
@noop(1)
@noop(2)
def foo():
    return 1
 
@noop(1)
@noop(lambda: None)
@noop(1)
def bar():
    return 1
 
pprint(inspect.getsourcelines(foo))
pprint(inspect.getsourcelines(bar))
History
Date User Action Args
2014-04-14 17:31:00ballingtsetrecipients: + ballingt
2014-04-14 17:31:00ballingtsetmessageid: <1397496660.33.0.566497694968.issue21217@psf.upfronthosting.co.za>
2014-04-14 17:31:00ballingtlinkissue21217 messages
2014-04-14 17:31:00ballingtcreate