Message216127
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)) |
|
Date |
User |
Action |
Args |
2014-04-14 17:31:00 | ballingt | set | recipients:
+ ballingt |
2014-04-14 17:31:00 | ballingt | set | messageid: <1397496660.33.0.566497694968.issue21217@psf.upfronthosting.co.za> |
2014-04-14 17:31:00 | ballingt | link | issue21217 messages |
2014-04-14 17:31:00 | ballingt | create | |
|